cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Condition runs multiple times

I've have a flow that filters current dates in an Excel column and then sends an e-mail with the filtered data. Except that it has a condition and when there are multiple rows with the current date it sends an e-mail for every filtered row data. Is there a way to prevent this, or a better solution? 

 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @dashiofhdfsdufs ,

in that case you can add a 'Condition' (so you'll still need one at the end) to check if the 'List rows...' action returned any values.

empty(<valueOutputFromListRows>) is equal to null

if it did, send the email, otherwise do nothing. It should look as the solution here.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

6 REPLIES 6
tom_riha
Super User
Super User

Hello @dashiofhdfsdufs ,

it's because of the 'Apply to each'. If you're using the whole 'Body' output of the 'Filter array' in the 'Condition' then you shouldn't need the loop. Once you get rid of it it should send only a single email with the HTML table.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Have tried to change the condition but it still send an email multiple times. Added a terminate item but that didn't help. 

 

The condition filters now on "formatDateTime(addDays(utcNow(), 7), 'yyyy-MM-ddT00:00:00.000Z')". This works but does send multiple emails when conditions are correct. 

Capture2.PNG

Hello @dashiofhdfsdufs ,

you still have a loop in your flow, it loops through all the rows and for each row it runs the 'Condition'. And if any of the rows meets the condition it'll send the email.

Instead of looping through all the rows try to filter them right away in the 'List rows...' action and send the whole result in the email.

Or filter them in the 'Filter array' action and then use output of that 'Filter array' to create the HTML table and send the email.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

That works, but now it sends an email even when there is no data to show. 

Hello @dashiofhdfsdufs ,

in that case you can add a 'Condition' (so you'll still need one at the end) to check if the 'List rows...' action returned any values.

empty(<valueOutputFromListRows>) is equal to null

if it did, send the email, otherwise do nothing. It should look as the solution here.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Thanks for the solution, I've adjusted the condition on the select option if the value output is null, and this worked as well

Capture4.PNG

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (2,751)