cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MLay22
Regular Visitor

Have an Action Run in Parallel Without Duplicating The Action

Hi,

 

I have a flow that works in the following way:

 

  1. Scheduled Start Time
  2. Retrieve an excel file in SharePoint that contains a list of Parameters for use in next step (Customer Name, Email, etc)
  3. Apply to Each
    1. Take value from step 2
    2. Power BI Export Paginated Report to PDF for each row of the Parameters from step 2
    3. Send an Email, this takes the Email Address from the excel file and attaches the PDF of the paginated report

The workspace is going to be backed by an Embedded Capacity. Currently testing the cheapest node, A1.

 

I have test on A1 and A4, when I run the flow, the action of exporting the Paginated report to PDF takes 36 seconds in both cases. So they both take the same amount of time to run.

Looking at the CPU usage the stats are as follows:

 

A1 Node:

Peaked at 40% briefly

Average of 3.5% over the 70 Minutes it took to run

 

A4 Node:

Peaked at 7.4% briefly

Average of 0.6% over the 70 Minutes it took to run

 

So obviously, as embedded capacity is charged on a timely basis of the service being active, I would like to get the most out of the usage. And currently the usage is quite low on this task.

 

The result I would like is to have my step 3 run in parallel. I will keep my example simple and say I want to have two branches running at a time (In reality I would like as much as I can have running before it becomes an issue for performance)

 

I would like Branch 1 to run report numbers 1,3,5,7,9 etc.

And I want Branch 2 to run report numbers 2,4,6,8 etc.

So there is no duplication.

 

In my flow here, you can see the two branches but obviously setup this way, they are both running the same reports at the same time.

(Just as an FYI, The action to Export Paginated Report to PDF is only running a second slower for each report, so that is, each branch is producing a report every 37 seconds)

 

Can anyone point me in the right direction?

Do I need to somehow split the Excel file list first, or can I configure the flow at the Parallel stage rather?

 

ThanksCurrent PF Setup.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MLay22
Regular Visitor

Unfortunately my lack of PA experience made me miss an obvious solution to this!

I did not have concurrency control enabled on my Apply to Each (degree of parallelism)
I enabled this and as expected, it ran multiple reports at once.

Run Reports in parallel 1.pngRun Reports in parallel 2.png

View solution in original post

4 REPLIES 4
MLay22
Regular Visitor

I am considering adding in another column in the excel file that populates each row with an id number.

 

Call the Column something like "Branch Number"

Then get each Branch to filter on it's specific number to only run the rows associated with it.

 

But, if there is a better way to achieve this, please let me know.

Hi @MLay22 

 

If you use length, you can get the number of rows in the value array returned by the excel action. Then you could div by 2 and create a range for both apply to each loops, range(0,div(length(value),2)) and range(add(1,div(length(value),2)).

 

Then call your objects in the apply to each as integer values, based on item() from the range. 

Hope that makes sense?

 

if not, I can try and mock up an example when I’m back home.

 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

Hi DamoBird365,

 

Thank you for taking the time to respond, I really appreciate it.

 

Okay, I understand what you're doing with splitting the excel file. I just lose you slightly when it comes to the item()

If it's not too much trouble, I think a mock up would be very helpful.

 

Wrapping report SS1.png

 

I've added in the range, which then causes my Parameters, which are currently dynamic content of the required columns, to change and thus the flow fails -

 

Before the Range:

Wrapping report SS3.png

 

 

 

 

 

 

 

 

After the Range:

Wrapping report SS2.png

 

 

 

 

 

 

 

 

 

I'm not sure where to include the item() as when I do, it creates additional Apply to Each control, both to the "Export Paginated reports to PDF" and to the "Send an Email"

MLay22
Regular Visitor

Unfortunately my lack of PA experience made me miss an obvious solution to this!

I did not have concurrency control enabled on my Apply to Each (degree of parallelism)
I enabled this and as expected, it ran multiple reports at once.

Run Reports in parallel 1.pngRun Reports in parallel 2.png

View solution in original post

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,468)