cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tomswaelen
Helper II
Helper II

Combining multiple Excels in Sharepoint into a single Excel file

I have a bunch of Excels that have identical tables (with different contents of course). I want to combine these Excels into one single Excel which has the exact same type of table as the other ones.

 

The flow below doesn't work, I think I'm not using the correct Sharepoint fields for the list rows action.

 

Can anyone help me on my way?

 

tomswaelen_0-1678461604211.png

 

19 REPLIES 19
grantjenkins
Super User
Super User

For your List rows present in a table, you should use the drop-down to select the Location (SharePoint Site) and Document Library. They should both be the same as what you used in Get files (properties only).

 

For File you should be using the Full Path property.

 

grantjenkins_0-1678493969192.png

 

How are you thinking of combined the Excel files? Are you going to extract all the data across these Excel files and output to a completely new Excel file that you have? Or are you using one of the existing Excel files and appending to it?

 

Also, how many items across all Excel files would you have (approximately)?


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
tomswaelen
Helper II
Helper II

@grantjenkins I'm thinking of combining all the Excel files in a Sharepoint location into one aggregation file. So not into one of the 'original' files. However, the aggregation Excel is identical to the original files; the only difference is that it should have all the data of the other files in it. After running the flow, the original files should be moved to a new (Archive) location in Sharepoint.

 

I'm thinking of running this flow every hour or so, so it should never be more than a 20-30 Excel files at a time, maximum.

 

Is this something that can be done with Power Automate Cloud?

tomswaelen
Helper II
Helper II

This is the flow I have at the moment, but even without the step to add the content of the single Excel files into the combination Excel, the flow fails.

 

Am I doing something wrong or is this just not possible with PA Cloud?

 

tomswaelen_0-1678791726478.png

 

tomswaelen
Helper II
Helper II

Another way to do this, would be to read the contents of Excel attachments and add the content of the table (always the same name) in those attachments to an aggregation Excel on Sharepoint. I have scoured the internet, but I cannot find a cloud flow that would easily do this.

 

The list rows action asks me for a Sharepoint address, but I need this to be the attachment of the e-mail.

Just to confirm - is you trigger going to be when a new email arrives with attachments. And you need to get the data from those attachments (Excel files) an combine them into a new Excel file? I didn't realize they were coming as attachments in an email before. If you can confirm, then I'll try to write up a complete solution tomorrow (1AM where I am at the moment - so off to sleep now).


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
tomswaelen
Helper II
Helper II

@grantjenkins  combining Excels on Sharepoint was actually a workaround I had been thinking about, so yes, the original idea was this:

 

1. E-mail arrives in a shared mailbox

2. E-mail contains an XLSX or XLSM attachment, which contains a table with always the same name and same columns

3. The contents of the table in this attachment are read and added to an Excel Online file which contains a table with the same columns as the attachments.

4. The e-mail is moved to a 'Processed' folder (I can probably figure this one out myself 😉 )

 

 

Another workaround is to have the e-mail body contain the necessary data instead of the attachment, but there are plenty of resources on the internet that explain how to do this.

Hopefully this is what you're looking for. Note that I've got the trigger on my own mailbox as I don't have a Shared mailbox setup. It will save each of the attachments temporarily, retrieve the data, then delete them.

 

For this example, I've got a folder called Processing within my Documents Library. And within there I have my main Excel file that will get added to over time. It has a Table called Table1 with Name and Age headers.

 

grantjenkins_0-1679212335010.png

 

grantjenkins_1-1679212377144.png

 

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

grantjenkins_2-1679212541329.png

 

When a new email arrives will trigger the flow when an email arrives with attachments. I've also set the Subject Filter to only pick up emails with a Subject of 'Processing" - you would have whatever you wanted here.

grantjenkins_3-1679212619083.png

 

For the trigger (above) I've also set Concurrency Control to On and set the Degree of Parallelism to 1. This is so that the flow won't run in parallel if we have multiple emails coming in at the same time. It will wait for the running flow to complete, then start the next one.

grantjenkins_11-1679213387807.png

 

grantjenkins_12-1679213395527.png

 

Apply to each attachment will iterate over each of the attachments.

grantjenkins_4-1679212650948.png

 

Create file will use the content from the attachment and create a temporary file within our Processing folder. I've used the following expression to ensure we always get a unique name, so we don't get into conflicts.

concat(
  guid(), 
  '.', 
  slice(items('Apply_to_each_attachment')?['name'], lastIndexOf(items('Apply_to_each_attachment')?['name'], '.'))
)

grantjenkins_5-1679212773205.png

 

List rows present in a table retrieves the rows from the file we just created. Note that I've manually typed Table1 assuming the table names will always be the same.

grantjenkins_6-1679212834723.png

 

Apply to each row iterates over each of the rows returned, and uses Add a row into a table to add each row into the master (Main.xlsx) file.

grantjenkins_7-1679212886927.png

 

Delete item deletes the file that was created (our attachment). Note that I manually typed Documents since it only shows Lists (not Libraries) in the dynamic data.

grantjenkins_8-1679212964135.png

 

 

For testing purposes, I've attached two .xlsx files and one .xlsm files, each with two rows of data.

grantjenkins_9-1679213115590.png

 

And the output in our Main.xslx file.

grantjenkins_10-1679213236104.png


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
tomswaelen
Helper II
Helper II

Hi @grantjenkins ,

 

I've tried replicating this flow, and testing it up until the get rows action, but the flow times out on the apply to each. The trigger works.

 

Also, in the add rows-step, how do you get the Excel field names in Power Automate? I don't understand as at that time, the flow does not know those names in edit mode?

 

tomswaelen_0-1679221965386.png

 

Using the Test Flow with this type of trigger can be a bit inconsistent (the attachment content can get corrupted).

 

It's best to send an email each time with attachments and let the flow run, then go into the Flow run itself. to see how it went For testing purposes, I just kept forwarding the email to myself, so it kept the attachments.


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
tomswaelen
Helper II
Helper II

@grantjenkins  OK, I'll try again.

 

But I also do not understand the 'Add row' step. How do you get the field names of the Excel attachment in the dynamic content window? I don't have those. (which seems logical to me, because the field names are 'theoretical' or 'virtual' at that point, the flow does not know these field names)

Ah sorry - because we type in the Table name manually, Power Automate can't infer the column names. In order to get what you need; you would use the following expressions.

 

item()?['Name']
item()?['Age']

//Format
item()?['Name of your header in Excel']

----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
tomswaelen
Helper II
Helper II

@grantjenkins  That seems to work, thank you 🙂

 

One final question, I'd like to move the created file to a separate folder, but I'm unsure how to call the file that has to be moved in the Sharepoint Move File action. 'Name' does not seem to be correct:

 

tomswaelen_0-1679309978927.png

 

Perhaps Path? Or Path/Name?

I'm not sure what you mean by created file? Do you mean the attachments that are temporarily created and then deleted?


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Yes, so instead of deleting the file, I'd like to move it to a Processed folder, but I'm unsure on how to call the file that was created in the previous step. 'Name' doesn't seem to work.

I think it would be the Identifier field from Create file.


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
tomswaelen
Helper II
Helper II

Hi,

 

No, tried that. The flow runs up until the 'Move file' step, where it fails.

What is the error message you get?


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
tomswaelen
Helper II
Helper II

Apparently, the syntax in the action is correct; I get this error message:

 

File 'Shared Documents/******************/3d3452d3-2e4a-4f23-a2f3-15157c92f162..xlsx' cannot be moved because it is in locked mode.
clientRequestId: bc122430-8c70-4d9d-8589-077661b1ff0b
serviceRequestId: bc122430-8c70-4d9d-8589-077661b1ff0b

Alliza_May
New Member

@tomswaelen did you end up getting this to work? Trying to achieve the same thing and not having any luck.

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (5,461)