cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
manu59
Level: Powered On

Split an Excel file with 4000 rows is too long

Hi everyone,

 

My goal is to read an Excel file and split it into multiple mail using a key.

In my example, with a 4000 rows Excel file, the flow should send 70 distinct mails.

 

But the flow is running slowly = it takes 30 minutes to create the 70 mails !

 

I used :

  • "Initialize variable" to store the key values
  • "list rows present in a table" into the array
  • use an "union" expression to combine the array with itself to get a result of unique values
  • for each key :
    • "filter array" with the current key 
    • "create HTML table"
    • "send email"
  • "create HTML

Do you think there is another solution to be more quick ?

key.JPGflow.JPG

 

Best regards

 

Thanks a lot

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Split an Excel file with 4000 rows is too long

Hi @manu59 

 

Exactly!!!!! That was what I was trying to convey. You use field itself and not the name of the string name.

 

Well done!

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

View solution in original post

14 REPLIES 14
Super User
Super User

Re: Split an Excel file with 4000 rows is too long

Hi @manu59 

 

Question. Do you know before-hand the keys that you'll be using? If you do, you could do a "For Each" on those keys and fetch only the ones you need by using the "Filter Query" in the "List Rows Present at a table." Power Automation would be more straightforward because you only would need to fetch the rows and send the email — no need to go over all the rows and to parse them.

 

The 30 minutes are going to:

  1. Fetching that significant amount of data
  2. Parsing that data so that you can create an email.

 

Then your Power Automation would be:

  1. For each key
  2. List Rows Present at a table where Filter Query has the "key eq ..."
  3. Build the HTML
  4. Send the email

 

A lot simpler, but this would only work if the keys are pre-defined.

 

Hope this helps you.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

manu59
Level: Powered On

Re: Split an Excel file with 4000 rows is too long

Hi @manuelstgomes,

 

Thanks for your answer.

 

Unfortunately I don't know the keys. 

Is there any action to get distinct values from an Excel file ?

In the "List rows" there is a "filter" condition and "order by" condition … does something exists with "group by" ?

 

Regards

Super User
Super User

Re: Split an Excel file with 4000 rows is too long

Hi @manu59 

 

No worries, we'll find a solution. No, there's not a group by, unfortunately..

 

I'm wondering if we could optimize by not querying the Excel files so many times. We fetch the full 4000 rows in the beginning, and we do a lot of queries to it in the "Apply to each." 

 

Let's try something different. Let's put the first fetch of the Excel into an array and use that Array as our Excel Source. Then we would only fetch the big Excel once and deal with all the information in Power Automation.

 

So what you need to do is the following:

  1. Put the Excel into an array
  2. Use the compose -> Filter Array to get each item

 

Here's your Power Automation and where to do the changes

flow.jpg

 

And here are the changes.

Screenshot_2019-12-16_at_10_18_00.jpgScreenshot_2019-12-16_at_10_18_05.jpg

 

Let's try this and see if you get better times. To be sure, copy your Power Automation into another and make these changes. If they don't work, just delete the Power Automation and you'll have your original one untouched. 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Highlighted
manu59
Level: Powered On

Re: Split an Excel file with 4000 rows is too long

Hi @manuelstgomes ,

 

I copied my flow (to have my original one untouched) and changed id, but time execution is not better = more than 30 mn.

 

I'm looking for another solution :

  1. Action "get rows" from Excel file = it's work
  2. Action "select" from result 1 to keep only column "KEY" = it's work
  3. I'm trying to use "union" from result 2 to keep different values = doesn't work

I Don't know how to write action "union"

 

Regards

 

Super User
Super User

Re: Split an Excel file with 4000 rows is too long

HI @manu59 

 

Just for me to understand, what's the new Power Automation? Can you share a demo?

Did you implement the changes like I recommended above?

 

Sorry so many questions so that I can help? 🙂

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

manu59
Level: Powered On

Re: Split an Excel file with 4000 rows is too long

Hi @manuelstgomes ,

 

Yes I implemented the changes like you recommended.

As you said "To be sure, copy your Power Automation into another and make these changes" = I created a copy.

and "If they don't work, just delete the Power Automation and you'll have your original one untouched. " = I deleted this flow.

 

I'm trying to get the Excel rows into an array, then use this array and more use the Excel file

union.JPG

 

 

 

 

manu59
Level: Powered On

Re: Split an Excel file with 4000 rows is too long

Hi @manuelstgomes ,

 

I think there's a mistake in what I did. So I rewrited the flow.

 

Know, when I add "Compose filter array" it give no result !

 

In the array "Excel", a row look like this :

{"@odata.etag":"","ItemInternalId":"74c3925e-747c-4d77-935f-111799f36a1b","MAGASIN":"4","PRENOM":"Cecile"...

For the name of the Key field I use "MAGASIN" and in the Key value the current value is {"MAGASIN":"4"}

 

What do you the error could be ?

 

Regards

 

Super User
Super User

Re: Split an Excel file with 4000 rows is too long

Hi @manu59 

 

Almost there don't worry 🙂

 

Have you tried putting the "MAGASIN" field in the filter? Something like this?

Screenshot_2019-12-16_at_10_18_05_copy.jpg

 

If yes, can you show me the Power Automation in that area so that I can try to figure out the issue?

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

manu59
Level: Powered On

Re: Split an Excel file with 4000 rows is too long

Hi @manuelstgomes ,

 

First I initialize an array from Excel.

I change the column's name from french to english to be easier for you to understand

 

array.JPG

I initialize a second array using "union" to keep distinct key value and apply "for each"

 

key.JPG

 

Yes I tried putting "KEY" field in the filter

 

foreach.JPG

 

 

 

 

 
Super User
Super User

Re: Split an Excel file with 4000 rows is too long

Hi @manu59 

 

You're putting the string "KEY" in the field. You need to put the field "KEY" so that the value contained in it can be matched with the number. Just select it from the Dynamic Content tab.

 

Makes sense?

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

manu59
Level: Powered On

Re: Split an Excel file with 4000 rows is too long

I succed to find a solution !

 

I get value of current item from "for each" (Pour chaque magasin) and put it in filter array with 

 

equal.JPG

 

Tanks a lot for all your explainations

Super User
Super User

Re: Split an Excel file with 4000 rows is too long

Hi @manu59 

 

Exactly!!!!! That was what I was trying to convey. You use field itself and not the name of the string name.

 

Well done!

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

View solution in original post

manu59
Level: Powered On

Re: Split an Excel file with 4000 rows is too long

And the new duration = great solution !!!!

 

duration.JPG

 

Best regards

 

Manu

Super User
Super User

Re: Split an Excel file with 4000 rows is too long

Hi  @manu59 

 

That's AWESOME!!!! 10x improvement!! 🙂

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (4,632)