Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Retrieving a column using get rows (v2) and then compare the result with another column in another table

Hi All - 

I have two tables as below:


I would like to grab all the ids from table A and would like to compare with ids from table B, and based on that I would like to identify the ids from table B which does not exist in table A (id 3 and 4 will be the one based on above tables).


For this I am using the get rows (v2) action and using the "Select Query" to retrieve the id column. Then I am initializing the variable with the type Array, here I am storing the output from my get rows action. When I tried testing this much progress I am getting the below error:


Here is the what the error message says:
"Flow save failed with code 'InvalidVariableInitialization' and message 'The variable action 'Initialize_variable' of type 'InitializeVariable' cannot be nested in an action of type 'Apply_to_each'.'."

Here is the screenshot of the flow:



I am not nesting it in "Apply to each", the flow is doing that part. 


Well, after this in theory I would like to create another get rows (v2), and compare the id of the table A column with the output of the variable, in Filter Query box. The expression would be something like this:



Id ne Output



Firstly, can someone please help me with the error message?
Secondly, am I in the right path? If there is a better way to do this then please let me know.


Thank you in advance!!

Super User
Super User


Use inside initialize variable action formula with the help of  Add dynamic content ->Expressions:




but you don't need a variable to execute the actions that follow. You can reference to the results of "Get_rows_(V2)" anywhere in the flow with the formula above. 

From my point of view it is useless to bring the item of the two tables inside PowerAutomate flow and compare it here, when you can create a view on Sql Server side and in the PowerAutomate flow read the results of that view. 

Hope it helps !

Helpful resources

2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Users online (2,415)