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 / Extract data from mult...
Power Automate
Unanswered

Extract data from multiple Excel files to single CSV

(0) ShareShare
ReportReport
Posted on by 30

Hello, I would like to set up a flow that pulls data from multiple Excel files on Sharepoint, and copies that data to a single CSV file.  Ideally, when triggering the flow, the user would specify a month, and it would only extract data where the "month" column equals the specified month.  And, the resulting CSV file name would contain the month, to differentiate it from previous month files.

 

Thank you for any assistance!

 

Example Source Tables: 

 

richzip_0-1697914672177.png          richzip_2-1697914816735.png       richzip_4-1697914920907.png

 

Resulting Output, when user selects month of 202304 (nothing is extracted for ID 456789, since month 202304 is not in that table)

 

richzip_5-1697914998624.png

 

 

 

 

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,315 Super User 2025 Season 2 on at

    hi @richzip 

     

    Unfortunately you didn't provide data on how the person is passing or selecting dates, so that we can understand which trigger to use for instance.

     

    Can you please provide more detail on how the user interacts and triggers this flow.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • ManishSolanki Profile Picture
    15,091 Super User 2025 Season 2 on at

    Hi @richzip 

     

    Please also specifies the expected number of inputs excel files.

     

    Thanks

  • richzip Profile Picture
    30 on at

    @FLMike @ManishSolanki  thank you both for your reply! I think I figured most of this out.  I have the flow set up with a manual trigger, including an input value.  Under the "list rows present in a table", I added the input value as a Filter  Query. 

     

    However, I may want to set up a 2nd input value that further filters the records.  When setting that up as an addition to the Filter Query, I got an error that I can only enter a single eq value.  So instead, I tried setting up a "condition", where the PSID column from my source files equals the 2nd input value.  None of the columns in my source data were selectable under Dynamic Content, so added ['PSID'] instead - that doesn't appear to work.

     

    @ManishSolanki each time this is run, there will be ~200 files

     

    richzip_1-1698071441506.png

     

     

    richzip_2-1698071464552.png

     

    richzip_4-1698072557252.png

     

     

     

     

     

     

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    This is how I would build the flow.

     

    However, if there was a LOT of files/rows and I had access to premium connectors, I'd probably do it differently so as to perform a bulk update to Excel.

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_0-1698219020243.png

     

    Manually trigger a flow is setup similar to yours where the person running the flow can enter the Month.

    grantjenkins_1-1698219568895.png

     

    Get files (properties only) will retrieve all the Excel files. I believe this will only return the first 100 files by default. If you have around 600 then you should change the Top Count to ensure it gets all files. In my example I've set it to 2000.

    grantjenkins_2-1698219723967.png

     

    To create the new Excel file where the combined output will go - I've created an Excel file to use as a Template with the Table and columns already created. This way we can get the content from that blank Excel file and create a new file based on it.

     

    Get file content using path gets the content from the Excel template.

    grantjenkins_3-1698219902662.png

     

    Create file uses the content from our Excel template and appends the Month as part of the file name.

    grantjenkins_4-1698219939412.png

     

    Apply to each file iterates over each of the files.

    grantjenkins_5-1698219972745.png

     

    List rows present in a table retrieves the rows from the current Excel file we are iterating over. I used the Identifier for the current file. Note that I've also set a Top Count here as the List rows present in a table action will only retrieve the first 256 rows by default (I'm not sure how many rows you have in your Excel files). Also note that I've set a filter to only bring back rows for the specified Month.

    grantjenkins_6-1698220102677.png

     

    Apply to each row iterates over each row in the current Excel file.

    grantjenkins_7-1698220147425.png

     

    Add a row into a table adds each of the rows returned into the Excel file we created. Because the Table name is dynamic we need to add the data dynamically. Note that I've also added the Sick and Vacation values for the Total using the add formula. It assumes there is always a value entered for Sick and Vacation, even if just 0.

    grantjenkins_8-1698220411974.png

     

    {
    "ID": @{item()?['ID']},
    "Month": @{item()?['Month']},
    "Sick": @{item()?['Sick']},
    "Vacation": @{item()?['Vacation']},
    "Total": @{add(float(item()?['Sick']), float(item()?['Vacation']))}
    }
  • richzip Profile Picture
    30 on at

    @Grant Thank you very much!  One other question.  I added another input to the trigger (Analyst), as well as a matching column in the source files.   Since the "list rows" step only allows a single eq value, I instead added a "filter array" step immediately after "list rows".  The flow ran, and filtered out the Month (from the "filter query" in "list rows), but it didn't filter for just the requested Analyst.

     

    richzip_0-1698245836655.png

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Not sure what the issue is here. The Filter array looks like it's using just this months data and then filtering down further on Analyst. I'd check the output of Analyst in both the output of List rows present in a table and the Manual trigger parameter to ensure they are what you expect.

  • richzip Profile Picture
    30 on at

    @grantjenkins It  did use just the requested month's data, but it did not filter to just the requested analyst.  The input is for Analyst = Rich, but it also extracted records with Analyst "John".  

     

    richzip_0-1698674884337.png

     

    richzip_1-1698675075512.png

     

    richzip_2-1698675388880.png

     

    richzip_3-1698675491585.png

     

     

     

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

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard