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 / After extracting 'Date...
Power Automate
Unanswered

After extracting 'Date' and adding rows into a table, sort by 'Date'

(0) ShareShare
ReportReport
Posted on by 24

Hi everyone,
I have a flow that extracts informtion: 'Transaction Date' and 'Amount' from images and adds extracted data into excel.
Can I somehow adjust my flow so it sorts the data by Date asc?

This is how the excel sheet looks

AusarZ_2-1714473062111.png

 


This is a step which adds rows:

AusarZ_1-1714472854631.png

For 'Amount' I have a function to replace commas with dots to make =sum() work.
Maybe I can put 'Transaction date' into some kind of 'sort by' function so it sorts data?

Categories:
I have the same question (0)
  • rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @AusarZ ,

     

    It looks like the easiest solution here is to create an Office Script to perform this action. The Office Scripts allows you to automate tasks inside Excel for Web, performing a similar role of VBA in Excel Desktop (but written in TypeScript). Also, the Office Scripts can be ran from Power Automate 🙂

     

    I ran a quick test with the following table:

    rzaneti_0-1714476462861.png

     

    Than I used the following Office Script:

    rzaneti_1-1714476506063.png

     

    And this was the result:

    rzaneti_2-1714476524873.png

     

     

    To create an Office Script, you just need to go to "Automation" tab in your Excel, and click in "New Script". Then a Code editor will appear in the right side of the screen, where you can insert your script:

    rzaneti_3-1714476607448.png

     

    To run it from Power Automate, you just use the "Run Script" action, and select the file and the script that you want to run:

    rzaneti_4-1714476741917.png

     

    Here is the full code: 

    function main(workbook: ExcelScript.Workbook) {
    
     const table = workbook.getTable('Table1') //returns the table
    
     table.getSort().apply([{key: 0, ascending: true}]) //sorts the table based in its firt column, in asc
    
    
    }
    

     

    From your end, make sure to change your table name in the following line:  const table = workbook.getTable([table name here, between quotes]). You can also change the index of the column that you want to use to sort the table, by changing the key property from 

    table.getSort().apply (zero means the first column, 1 means the second, and so on). 

     

    Finally, I wrote some blog posts about this topic, and I'm sharing it here in case of you or any other user wants to learn more about Office Scripts:

    - Office Scripts, the new VBA: http://digitalmill.net/2023/06/10/office-scripts-the-new-vba/ 

    - Getting started with Office Scripts: http://digitalmill.net/2023/06/19/get-started-with-office-scripts/ 

    - Accessing Excel ranges with Power Automate: http://digitalmill.net/2023/09/01/accessing-excel-ranges-with-power-automate/ 

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/ 
    https://www.linkedin.com/in/raphael-haus-zaneti/ 

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard