cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mr-dang
Community Champion
Community Champion

How do I filter data in Flow?

Use case: students earn classroom money. Their transactions are recorded in one table, and another table called 'Bank' calculates a total balance. I am able to send out an email with a summary of everyone's balances (see image below).

 

2018-03-05 (3).png

 

My steps:

  1. Get rows from the table.
  2. Select relevant data: name, balance, class.
  3. Create an HTML table.
  4. Send an email with that HTML table. It works.

Problem: I want to filter the students based on their classroom, then email each teacher only data for their class. Currently I can only send out the whole thing as I'm testing out the Flow.

 

I tried the filter data operation two ways:

  • I tried filtering the result from the Get in step 1. The result can be used as the input for step 2, but its columns can't be referenced in later steps.
  • I tried filtering the result from the Select in step 2. The output from Select can be the input for the Filter, but its columns can't be referenced in the filter.

 

Questions:

  • How do I filter data in a Flow?
  • Which step do I try to filter data?

 

I imagine I could execute more of the filter from within PowerApps, but I would like to shift this operation to a recurrence so that it is automated.

 

Any help is appreciated.

 

_

Microsoft Employee
@8bitclassroom
1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @mr-dang,

 

Could you please share a full screenshot of your flow's configuration?

Could you please show a bit more about your Google Excel table?

Further, do you want to filter records based on classroom?

 

I have created a Google Excel table on my side and the data structure of it as below:5.JPG

 

I assume that you want to filter records whose Class is equal to 1, please take a try with the following workaround:

  • Add a "Recurrence" trigger, Interval set to 1 and Frequency set to Day.
  • Add a "Get rows" action, specify File and Worksheet.
  • Add a "Filter array" action, From set to output of "Get rows" action, within Condition box, click "Edit in advanced mode", type the following formula:
@equals(item()?['Class'], '1')
  • Add a "Select" action, From set to output of "Filter array" action, Within Map entry, type there entries. The key of first entry set to Student Name and the corresponding value set to following formula:
item()?['Student_x0020_Name']

The key of second entry set to Current Balance and the corresponding value set to following formula:

item()?['Current_x0020_Balance']

The key of third entry set to Class and the corresponding value set to following formula:

item()?['Class']

Note: The Student Name, Current Balance and Class are columns in my Google sheet, on your side, you could get the column value within your Google sheet with following formula:

item()?['ColumnNameInYourGoogleSheet']

If there is a space within the column name, you must replace the space with '_x0020_' within above formula (WDL expression).

 

  • Add a "Create HTML table" action, From set to output of "Select" action, Include Headers set to Yes.
  • Add a "Send an email" action, Body field set to output of "Create HTML table" action, is HTML field set to Yes.

Image reference:6.JPG

 

7.JPG

 

The flow works successfully as below:8.JPG

 

9.JPG

 

 

More details about using expression in flow actions, please check the following article:

https://flow.microsoft.com/en-us/blog/use-expressions-in-actions/

 

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-xida-msft
Community Support
Community Support

Hi @mr-dang,

 

Could you please share a full screenshot of your flow's configuration?

Could you please show a bit more about your Google Excel table?

Further, do you want to filter records based on classroom?

 

I have created a Google Excel table on my side and the data structure of it as below:5.JPG

 

I assume that you want to filter records whose Class is equal to 1, please take a try with the following workaround:

  • Add a "Recurrence" trigger, Interval set to 1 and Frequency set to Day.
  • Add a "Get rows" action, specify File and Worksheet.
  • Add a "Filter array" action, From set to output of "Get rows" action, within Condition box, click "Edit in advanced mode", type the following formula:
@equals(item()?['Class'], '1')
  • Add a "Select" action, From set to output of "Filter array" action, Within Map entry, type there entries. The key of first entry set to Student Name and the corresponding value set to following formula:
item()?['Student_x0020_Name']

The key of second entry set to Current Balance and the corresponding value set to following formula:

item()?['Current_x0020_Balance']

The key of third entry set to Class and the corresponding value set to following formula:

item()?['Class']

Note: The Student Name, Current Balance and Class are columns in my Google sheet, on your side, you could get the column value within your Google sheet with following formula:

item()?['ColumnNameInYourGoogleSheet']

If there is a space within the column name, you must replace the space with '_x0020_' within above formula (WDL expression).

 

  • Add a "Create HTML table" action, From set to output of "Select" action, Include Headers set to Yes.
  • Add a "Send an email" action, Body field set to output of "Create HTML table" action, is HTML field set to Yes.

Image reference:6.JPG

 

7.JPG

 

The flow works successfully as below:8.JPG

 

9.JPG

 

 

More details about using expression in flow actions, please check the following article:

https://flow.microsoft.com/en-us/blog/use-expressions-in-actions/

 

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

 

how would this work if the class ("1", "2", etc.) was actually the email address of the teacher, and this email address was in the source table being queried? The goal being how to simply iterate over each email address and summarize just those applicable rows into the html table that is sent out in email, and not "hard code" assumptions into the Flow logic about how many classrooms (or email targets) there will be?

 

I'm new, and trying to adapt this post into my similar use case of grabbing a subset of rows from an Excel sheet and emailing them as an html table to the owner (in a single email, not 1 email for each row.) Like a "group by email" expression.

SwapnaNethi
Helper I
Helper I

Hello, I am facing error with my filter condition . i am receiving below error

 

InvalidTemplate. The execution of template action 'Filter_array_2' failed: The evaluation of 'query' action 'where' expression '@equals(item()?['adname'], items('Apply_to_each')['name'])' failed: 'The template language expression 'equals(item()?['adname'], items('Apply_to_each')['name'])' cannot be evaluated because property 'adname' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.

timodondino
Frequent Visitor

@v-xida-msft 
Hey Kris,

 

your solution looks very good but I have the same question like @RobWickham. How do you work with the filter array if your table is dynamic. In your case you compared the values in column "class" to a specific number. What if I want to create a table for each number and I don't want to build a single flow for every of these numbers. I'm facing this problem right now because unfortunately it doesn't work if I just put dynamic content on both sides of this comparison in the filter array.

Best regards

Timo

 

Helpful resources

Announcements
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

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (45,999)