cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mattroed
Frequent Visitor

Counting True Statements

I am trying to update items in an excel table based on a user input. I first get the rows of the table and then use an apply to each control to go through each item. If the user input item already exists in the table I simply add to another column on the table. This works fine. But if the ID that the user inputs isn't already in the table, I want to add the new ID as a new row. I thought I could use a variable and just count how many true's returned in my condition control but it did not work (i.e. if there were zero controls it would know to create a new row). Any ideas on how to count the number of true's that return for a condition control that is going through an apply to each control?

1 ACCEPTED SOLUTION

Accepted Solutions
efialttes
Super User III
Super User III

Hi!

Can you share a screenshot from your current flow design?

You can follow two different approaches:

1.-Just before your 'Apply to each'  add an 'initialize' variable, let's name it counter, type integer, value 0. Now, inside your apply to each, everytime you find  match, increment it by means of 'Increment variable' action block. So after 'Apply to Each' just need to add a condition to evaluate if 'counter' variable is still 0.

2.-Instead of an apply to each approach, you can implement a Filter (either by means of Filter Query input in your 'List rows present in a table' or by means of an input array action block. So you filter rows matching your condition. After filtering, just need to add a condition to evaluate if filter outputs length variable is 0.

First approach is easier to implement. Secon approach is more efficient, but more complex also

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

4 REPLIES 4
efialttes
Super User III
Super User III

Hi!

Can you share a screenshot from your current flow design?

You can follow two different approaches:

1.-Just before your 'Apply to each'  add an 'initialize' variable, let's name it counter, type integer, value 0. Now, inside your apply to each, everytime you find  match, increment it by means of 'Increment variable' action block. So after 'Apply to Each' just need to add a condition to evaluate if 'counter' variable is still 0.

2.-Instead of an apply to each approach, you can implement a Filter (either by means of Filter Query input in your 'List rows present in a table' or by means of an input array action block. So you filter rows matching your condition. After filtering, just need to add a condition to evaluate if filter outputs length variable is 0.

First approach is easier to implement. Secon approach is more efficient, but more complex also

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

I believe this solution will work. I'm still getting hung up in one area though. Any idea on how I can convert a date from integer to 'MM/dd/yyyy'? I need to do that to compare in a condition. 

mattroed
Frequent Visitor

I was able to figure out how to convert an integer to a date. Here is the code:

 

if(empty(<insert date integers>),'',addDays('1899-12-30',int(<insert date integers>),'MM/dd/yyyy'))

Sorry I am back too late to help! But you did it yourself! Congrats!

 

Excel, right? 1899-12-30 is an unforgettable date! 😉

Happy Flowing!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (26,999)