web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Script to Sort a Colum...
Power Automate
Unanswered

Script to Sort a Column in a Table in an Excel

(0) ShareShare
ReportReport
Posted on by 16

I created an Excel using Power Automate, with Table and Rows filled.

As there is no OOTB feature available to sort tables during the creation of Excel and Tables, is it possible to implement a script of the following requirement?

1. Select a table in the first sheet of an Excel
2. With the table containing headers, sort column H by ascending Date

SysAdmSG_0-1716458793188.png

 


If it is possible, I appreciate any help with regards to forming the script.

Thank you.

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    on at

    Hi @SysAdmSG ,

     

    Please try this

    function main(workbook: ExcelScript.Workbook) {
    	let table1 = workbook.getTable("Table1");
    	// Sort on table: table1 column index: '7'
    	table1.getSort().apply([{key: 7, ascending: true}]);
    }

     

    Best Regards,

    Wearsky

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard