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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Merge two Excel files ...
Power Automate
Unanswered

Merge two Excel files received in an email

(0) ShareShare
ReportReport
Posted on by 4

Hello,
Here is my problem, I can't find out how from Power Automate.
- When I receive an email
- Merge the two Excel files received
- Send them to another recipient

For the reception and sending of mail, no problem,
However, I can't merge the files, because it treats the problem in "apply to each" mode and so I receive two emails with two Excel files, instead of one email with the merged Excel files.

How to solve this problem? Thank you in advance for your help.

Categories:
I have the same question (0)
  • David- Profile Picture
    1,254 on at

    I don't have time to build a flow to show an example of  this, but all of the actions exist to do this. You would use these actions:

    1. I assume your trigger is When a new mail arrives
    2. Follow this with an Apply to each that has output of the Attachments
    3. Use the Create file action to save the two Excel files somewhere
    4. Then use List rows present in a table to get the data from one of the spreadsheets
    5. Then use another Apply to each with the data from getting the rows above
    6. Next use Add a row into a table of your second spreadsheet
    7. The two are now combined and you can send the second spreadsheet via e-mail

    You will need to do some checks along with way. You'll probably need to check that both attachments are Excel files, and you will probably need to check to make sure there are only two Excel files attached. It will look something like this (none of these actions are configured and I have not tested this):

    capture_16-9-2022_9398.jpeg

  • zacharie_touama Profile Picture
    4 on at

    Thank you for your reply, but how can I find out the name of the table in the Excel file I received by email?

  • David- Profile Picture
    1,254 on at

    I hadn't thought about that, as that will complicate things. You could check to see what the tables are named in your existing files. If there is only one table and nobody has renamed them, the table should be named Table1, which you can then enter as a custom value in the Excel actions. Otherwise, there is a Get tables action you can use to get them from each spreadsheet.

     

    That will greatly complicate things if there are more than one table in each, because then you will need to do an apply to each for each table and then also do checks to make sure the table exists in both spreadsheets as well. 

     

    Hopefully someone sees your post and has actually created and tested a flow with your use case.

  • zacharie_touama Profile Picture
    4 on at

    Thanks @David- , I have another problem, i can't select the ID of the sharepoint file previously created (on apply to each section) , it doesn't appear on dynamic content on "list raw to table" section

    zacharie_touama_0-1663338024144.png

     

  • David- Profile Picture
    1,254 on at

    As I mentioned, this is not something I have done before, but what I provided was a suggestion. However, I put something together that may work but I have not tested as so far my flow is not getting triggered when the e-mail arrives with the conditions I set.

     

    But I put two files in the location where you are going to create the files from the attachments with predefined names and set them up with a table that contains data for your process. You could name the files mergefile1.xlsx and mergefile2.xlsx.

     

    The in your flow initialize a number variable named AttachmentCount with the default value of 1. When you create the file, hard code the filename and use the AttachmentCount variable to set the file number: mergefile[AttachmentCount].xlsx.

     

    Then in your get file set it up to use the existing file in your document library and in the add rows do the same thing. Your flow will look like this:

    capture_16-9-2022_13113.jpeg

    The one thing I don't know what will happen since I have not done something like this will be how the create file action reacts to the existing files. I am hoping that they'll overwrite them and not create a new file with a number attached to the end, as there are no options to tell the flow what to do if the file exists already.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 86 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 55

#3
Ellis Karim Profile Picture

Ellis Karim 53 Super User 2026 Season 1

Last 30 days Overall leaderboard