cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Check whether Value Exists in Column from different Table ('VLOOKUP' within Condition)

Hi,

 

I am currently building a flow that sends e-mails listed in an Excel sheet named 'Mails'.

If the current date is less or equal than Today, it will send the e-mail.

When it sends the e-mail, it always writes a record in the table named 'Mails_History'.

 

This all works fine, however, I now want before the mail will be send check whether the 'ID' of table 'Mails' already exists in table 'Mail_History' (there the column I want to check is called 'ID_MH') .

 

Below is my current flow. What goes wrong is that obviously for each Mails.ID it checks ALL the records of Mails_History.ID_MH. And it will turn 'False' whenever it finds a similar ID, but unfortunately, it will for each record when it finds a different ID_MH turn 'True'. How to make sure it checks the entire list AND ONLY THEN return True/False?

 

titatovenaar_0-1609957142029.png

 

Any suggestions will be greatly appreciated!

 

1 ACCEPTED SOLUTION

Accepted Solutions
tom_riha
Super User
Super User

Hello @Anonymous ,

instead of 'Apply to each' and a 'Condition' inside, I'd use 'Filter Array' action. In the 'Filter Array' use the same filter as you currently have in the condition, to filter only rows where ID_MH contains ID. That will take all rows in the array and return only the ones that fit the condition.

After the 'Filter Array', add a condition to check how many rows were returned. If it's 0 = there wasn't any row where the ID_MH contains ID, the array is empty. If it's more than 0 then there's at least one row where ID_MW contains ID. Then you can act accordingly to that.

I prefer to use length(...) expression to check the number of rows returned.

length([array])

Note:
[array] is the output from the 'Filter Array' action, the final expression should be something like: length(body('Filter_array'))

It should look similar to the flow below, with the difference that I'm using SharePoint as the source.

image.png



[ 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

2 REPLIES 2
tom_riha
Super User
Super User

Hello @Anonymous ,

instead of 'Apply to each' and a 'Condition' inside, I'd use 'Filter Array' action. In the 'Filter Array' use the same filter as you currently have in the condition, to filter only rows where ID_MH contains ID. That will take all rows in the array and return only the ones that fit the condition.

After the 'Filter Array', add a condition to check how many rows were returned. If it's 0 = there wasn't any row where the ID_MH contains ID, the array is empty. If it's more than 0 then there's at least one row where ID_MW contains ID. Then you can act accordingly to that.

I prefer to use length(...) expression to check the number of rows returned.

length([array])

Note:
[array] is the output from the 'Filter Array' action, the final expression should be something like: length(body('Filter_array'))

It should look similar to the flow below, with the difference that I'm using SharePoint as the source.

image.png



[ 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. ]
Anonymous
Not applicable

Perfect suggestion! Works like a charm. Thanks 🙂

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,368)