How To Filter Excel Table Rows In Power Automate: Text Numbers, Dates
If you use the Power Automate Excel action to list rows present in a table you will notice an option to filter the result. In this short guide I will show you how to filter Excel table rows in Power Automate. I’ll share examples of how to write odata queries to filter text values in a spreadsheet. Additionally, I will also provide a workaround for filtering number and date data types which cannot be handled using odata queries.
Table of Contents
• Create An Excel Table In A Spreadsheet
• Filter An Excel Table Text Column In Power Automate
◦ Text Column Equals
◦ Text Column Does Not Equal
◦ Text Column Contains
◦ Text Column Starts With
◦ Text Column Ends With
• Filter A SharePoint Number Column In Power Apps
◦ Number Column Is Equal To
◦ Number Column Is Greater Than Or Less Than
◦ Number Column Is Between Two Values
• Filter A SharePoint Date Column In Power Apps
◦ Date Column Is Equal To
◦ Date Column Is Greater Than Or Less Than
◦ Date Column Is Between Two Values
Create An Excel Table In A Spreadsheet
Spreadsheet data must be inside of an Excel table for Power Automate to use it. To convert a range into a table, place the cursor inside of the range and select the Table button from the menu.
When the Excel table is created a new tab appears on the menu called Table Design. Place the cursor inside of the table and update the table name to tblSales.
For Power Automate to open the Excel file it must be stored in either SharePoint or OneDrive. Go to SharePoint and create a new Document Library named Sales Team. Then drag and drop the Sales Transactions spreadsheet into the Document Library.
This data can be copied into your own spreadsheet if you’d like to practice filtering Excel data with Power Automate.
TransactionDate | Customer | Amount |
1/1/2023 | Jacks Meat Shop | 310 |
1/3/2023 | Bridgewater Mill | 700 |
1/3/2023 | Jacks Meat Shop | 650 |
1/3/2023 | Green Valley Dairy | 890 |
1/4/2023 | Bridgewater Mill | 330 |
1/4/2023 | Friendly Farms | 1000 |
1/4/2023 | Green Valley Dairy | 290 |
1/5/2023 | Bridgewater Mill | 930 |
1/5/2023 | Jacks Meat Shop | 210 |
1/6/2023 | Friendly Farms | 710 |
1/6/2023 | Green Valley Dairy | 930 |
1/6/2023 | Friendly Farms | 810 |
Filter An Excel Table Text Column In Power Automate
Excel tables can be filtered by writing an ODATA query. With ODATA queries we can use the following operations: equals, does not equal, contains, startswith, endswith.
Text Column Is Equal To
Write this ODATA query to filter the Excel table where the Customer column is equal to Friendly Farms.
Filter Query:
Customer eq 'Friendly Farms'
Output array:
TransactionDate | Customer | Amount |
1/4/2023 | Friendly Farms | 1000 |
1/6/2023 | Friendly Farms | 710 |
Text Column Does Not Equal
Use this ODATA query to filter the Excel table where the Customer column does not equal Friendly Farms.
ODATA Filter Query:
Customer ne 'Friendly Farms'
Output Array:
TransactionDate | Customer | Amount |
1/1/2023 | Jacks Meat Shop | 310 |
1/3/2023 | Bridgewater Mill | 700 |
1/3/2023 | Jacks Meat Shop | 650 |
1/3/2023 | Green Valley Dairy | 890 |
1/4/2023 | Bridgewater Mill | 330 |
1/4/2023 | Green Valley Dairy | 290 |
1/5/2023 | Bridgewater Mill | 930 |
1/5/2023 | Jacks Meat Shop | 210 |
1/6/2023 | Green Valley Dairy | 930 |
1/6/2023 | Bridgewater Mill | 810 |
Text Column Contains
Input this ODATA query to filter the Excel table where the Customer column contains a substring with the word Shop.
ODATA Filter Query:
Customer contains 'Shop'
Output Array:
TransactionDate | Customer | Amount |
1/1/2023 | Jacks Meat Shop | 310 |
1/3/2023 | Jacks Meat Shop | 650 |
1/5/2023 | Jacks Meat Shop | 210 |
Text Column Starts With
Write this ODATA query to filter the Excel table where the Customer column starts with the word Bridge.
ODATA Filter Query
Customer startswith 'Bridge'
Output Array:
TransactionDate | Customer | Amount |
1/3/2023 | Bridgewater Mill | 700 |
1/4/2023 | Bridgewater Mill | 330 |
1/5/2023 | Bridgewater Mill | 930 |
1/6/2023 | Bridgewater Mill | 810 |
Text Column Ends With
Use this ODATA query to filter the Excel table where the Customer column ends with the word Dairy.
ODATA Filter Query:
Customer endswith 'Dairy'
Output Array:
TransactionDate | Customer | Amount |
1/3/2023 | Green Valley Dairy | 890 |
1/4/2023 | Green Valley Dairy | 290 |
1/6/2023 | Green Valley Dairy | 930 |
Filter An Excel Table Number Column In Power Automate
Number columns in an Excel table cannot be filtered properly using an ODATA query because they appear as text. The solution is to convert those columns to a number after the data has been retrieved from the file. Then we can use all of the expected operators to filter – equals, does not equal, greater than, less than, greater than or equal to, less than or equal to and does not equal.
Number Column Is Equal To
Create these actions in Power Automate with the following values:
- Excel for Business – List rows present in a table
- Data Operations – Select
- Data Operations – Filter Array
Power Automate Expressions:
Select: Convert Amount To Number
float(item()?['Amount'])
Filter array: Amount Eq 1000
item()?['Amount']
Output array:
TransactionDate | Customer | Amount |
1/4/2023 | Friendly Farms | 1000 |
Number Column Is Greater Than Or Less Than
Use these actions in Power Automate with the following values:
- Excel for Business – List rows present in a table
- Data Operations – Select
- Data Operations – Filter Array
Power Automate Expressions:
Select: Convert Amount To Number
float(item()?['Amount'])
Filter array: Amount GTE 500
item()?['Amount']
Output array:
TransactionDate | Customer | Amount |
1/3/2023 | Bridgewater Mill | 700 |
1/3/2023 | Jacks Meat Shop | 650 |
1/3/2023 | Green Valley Dairy | 890 |
1/4/2023 | Friendly Farms | 1000 |
1/5/2023 | Bridgewater Mill | 930 |
1/6/2023 | Friendly Farms | 710 |
1/6/2023 | Green Valley Dairy | 930 |
1/6/2023 | Bridgewater Mill | 810 |
Number Column Is Between Two Values
Add these actions in Power Automate with the following values:
- Excel for Business – List rows present in a table
- Data Operations – Select
- Data Operations – Filter Array
Power Automate Expressions:
Select: Convert Amount To Number
float(item()?['Amount'])
Filter array: Amounts Between 300 to 700
@and(greaterOrEquals(item()?['Amount'],300),lessOrEquals(item()?['Amount'],700))
Output array:
TransactionDate | Customer | Amount |
1/1/2023 | Jacks Meat Shop | 310 |
1/3/2023 | Bridgewater Mill | 700 |
1/3/2023 | Jacks Meat Shop | 650 |
1/4/2023 | Bridgewater Mill | 330 |
Filter An Excel Table Date Column In Power Automate
Date columns in an Excel table cannot be filtered properly using an ODATA query because they appear as an Excel number (serial number) stored as text. The solution is to convert those columns to a number after the data has been retrieved from the file. Then we must also convert the filter date into a serial number as well. Once this is done, we can use all of the expected operators to filter – equals, does not equal, greater than, less than, greater than or equal to, less than or equal to and does not equal.
Date Column Is Equal To
Create these actions in Power Automate with the following values:
- Excel for Business – List rows present in a table
- Data Operations – Select
- Data Operations – Compose
- Data Operations – Compose
- Data Operations – Filter Array
Power Automate Expressions
Select: Convert Transaction Date To Integer
int(item()?['TransactionDate'])
Compose: Selected Date As Excel Number
int(add(div(sub(ticks(outputs('Compose:_Selected_Date')),ticks('1900-01-01T00:00:00Z')),864000000000),1))
Filter array: Selected Date Eq 2023-01-04
item()?['TransactionDate']
outputs('Compose:_Selected_Date_As_Excel_Number')?['SelectedDate']
Output array:
TransactionDate | Customer | Amount |
1/4/2023 | Bridgewater Mill | 330 |
1/4/2023 | Friendly Farms | 1000 |
1/4/2023 | Green Valley Dairy | 290 |
Date Column Is Greater Than Or Less Than
Use these actions in Power Automate with the following values:
- Excel for Business – List rows present in a table
- Data Operations – Select
- Data Operations – Compose
- Data Operations – Compose
- Data Operations – Filter Array
Power Automate Expressions:
Select: Convert TransactionDate To Integer
int(item()?['TransactionDate'])
Compose: Start Date As Excel Number
int(add(div(sub(ticks(outputs('Compose:_Start_Date')),ticks('1900-01-01T00:00:00Z')),864000000000),1))
Filter array: Transaction Dates GTE 2023-01-04
item()?['TransactionDate']
outputs('Compose:_Start_Date_As_Excel_Number')?['StartDate']
Output array:
TransactionDate | Customer | Amount |
1/4/2023 | Bridgewater Mill | 330 |
1/4/2023 | Friendly Farms | 1000 |
1/4/2023 | Green Valley Dairy | 290 |
1/5/2023 | Bridgewater Mill | 930 |
1/5/2023 | Jacks Meat Shop | 210 |
1/6/2023 | Friendly Farms | 710 |
1/6/2023 | Green Valley Dairy | 930 |
1/6/2023 | Bridgewater Mill | 810 |
Date Column Is Between Two Values
Add these actions in Power Automate with the following values:
- Excel for Business – List rows present in a table
- Data Operations – Select
- Data Operations – Compose
- Data Operations – Compose
- Data Operations – Compose
- Data Operations – Filter Array
Power Automate Expressions:
Select: Convert TransactionDate To Integer
int(item()?['TransactionDate'])
Composes: Dates As Excel Numbers
int(add(div(sub(ticks(outputs('Compose:_Start_Date')),ticks('1900-01-01T00:00:00Z')),864000000000),1))
int(add(div(sub(ticks(outputs('Compose:_End_Date')),ticks('1900-01-01T00:00:00Z')),864000000000),1))
Filter array: Dates Between 2023-01-02 And 2023-01-04
@and(greaterOrEquals(item()?['TransactionDate'], outputs('Compose:_Dates_As_Excel_Numbers')?['StartDate']),lessOrEquals(item()?['TransactionDate'], outputs('Compose:_Dates_As_Excel_Numbers')?['EndDate']))
Output array:
TransactionDate | Customer | Amount |
1/3/2023 | Bridgewater Mill | 700 |
1/3/2023 | Jacks Meat Shop | 650 |
1/3/2023 | Green Valley Dairy | 890 |
1/4/2023 | Bridgewater Mill | 330 |
1/4/2023 | Friendly Farms | 1000 |
1/4/2023 | Green Valley Dairy | 290 |
Did You Enjoy This Article? 😺
Subscribe to get new Power Apps & Power Automate articles sent to your inbox each week for FREE
Questions?
If you have any questions or feedback about How To Filter Excel Table Rows In Power Automate: Text Numbers, Dates please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.
In the Number Column Is Equal To can’t you filter directly? Like this:
Is the additional step for better readability?
Robert,
Yes, your method is would be shorter. But I added the Select statement to convert all Amount values from text to number. I believe this would be desirable in most flows 🙂
Great question!
Totally love the cat picture you attached to this!
Jerry,
Me too. It’s one of the better ones for sure.
Hey Matt – great work on putting this all together! As discussed – I wanted to add that as of writing this the excel connector has a couple limitations – it will only support an odata filter on 1 column in your excel file – so if you need to filter on a couple columns – you will want to use odata and then use the Power Automate ‘Filter’ action (data operations) to further refine your record set. Hope that helps anyone out there!
Also – odata filter on the excel column will only work if the excel column has no spaces in its name! Again hope that helps peeps using this connector!
Hey Rich,
I love your comment. I am currently trying to filter my excel data by 2 columns, sadly i have hit a dead end because the odata only allows filtering by 1 column. Which lead me here to this article. Your are absolutely right by giving out the steps on how to achieve refined data if you want to filter through 2 columns.
Hi Matthew – this is incredibly helpful! 😀
I’m trying to filter dates between ‘now’ and ‘-15’ days, so I think this would work great however is there a way to then present the output into an email?
I managed to create a filter array that gets me the output I need but can’t see anyway of presenting that output into a send email when I do it this way.
@greaterOrEquals(item()?[‘Date of Incident’], formatDateTime(addDays(utcNow(), -15), ‘yyyy-MM-ddTHH:mm:ssZ’))
Thanks,
Josh
Josh,
I would place the body of the Filtered Array into a Data Operations – Create An HTML table action. Then you can use it in the body of an email.
I am scratching my head at this. Great article. I came across this just at the right time. Unfortunately it hasn’t worked for me. It’s definitely me doing something wrong. I have an excel sheet with a table with headers. My column “ Diarised Date” is filled in with a date to call the customer back. When I used you method for date equal to I came across a couple of problems. I can only find compose, not compose selected date and also the compose selected date as excel number. I have tried just with compose I could find errors kept coming up. Please can you help?
Terry,
“Compose” is an action. “Compose Selected Date” and “Compose Selected Date As Excel Number” are renamed Compose actions. I believe you have mistaken them for distinct and separate actions in Power Automate. Use “Compose” and simply rename it as the tutorial shows. It will work then 🙂
Also change the column ‘Diarised Date’ tp DiarisedDate’ with no spaces
Hello Matthew,
I am designing a workflow that will trigger twice a day at 6 AM and 6 PM and compile all the MS form submissions that happen between 6 AM to 6 PM and then 6 PM to 6 AM (the next day). I have two questions
1- How can I pass date and time together for the start time and the end time
2- I tried to use the filter array condition in your last case of “Date Column Is Between Two Values” and it gave me an invalid expression error.
I am curious if you can help.
Thanks,
Vaibhav
Viabhav,
1. This technique works for datetimes with one modification. Instead of making TransactionDate and INT your should make it a FLOAT. Time is expressed as a decimal. (Example: 1/1/2024 1:00 AM = 45292.0416666667)
2. I have done my own tutorial from scratch to look for an error but it worked perfectly. I believe the error is on your side somewhere.
I am creating a Power Automate flow that filters by a Number Column Is Greater Than Or Less Than. however, I keep getting an invalid template error. So I recreated your example as i see it on the site and get the same error. Has something changed? Here is the error:
InvalidTemplate
The execution of template action ‘Filter_array’ failed: The evaluation of ‘query’ action ‘where’ expression ‘@greaterOrEquals(item()?[‘Amount’],500)’ failed: ‘The template language function ‘greaterOrEquals’ expects two parameter of matching types. The function was invoked with values of type ‘String’ and ‘Integer’ that do not match.’.
Donald,
I have tested my tutorial based on your comments and its working for me. Here’s what I think the issue is. The Amount parameter is likely still a text string. Please double check that it was converted to a float inside of the Select action using the expression float(item()?[‘Amount’]).
If this does not work, please send me a few screenshots. It’s important to me that this tutorial is working well for everyone.
Hi Matthew,
Thanks for your repsonse. I have inputted the information as directed. I have placed the excel file in Teams (Sharepoint). each step inputs the same except under Select the float expression thumbnail looks different and in the Filter Array Step the item thumbnail is different than your pictures. not sure why as I am inputting the information as the same. Here is a picture of the output Select and Filter Array
here is the Filter Array screenshot
Donald,
Please show me the expression you wrote in the Select action. I can tell it’s not properly converting the Amount from a String to a Float data type.
Sure! Thanks for your help! Here is the peak code for select.
here is also the Parameter view with the expression I inputted
Donald,
The expression looks correct. I wonder if the new Power Automate editor is the cause of it not evaluating properly. They don’t have all the kinks worked out yet.
Delete the Select action. Save. Go back to the classic editor. Add the Select action back with the exact same code. And tell me if that worked.
Matthew,
That was it!! I didn’t realize that the editor would cause this type of problem. it seems it turned on by default in tenant. I will continue to use the classic editor. Thanks for your help!
Donald,
You’re welcome. The moment I saw the new flow editor I had a hunch it was the problem. Anyone using it… we’re all unofficial beta-testers right now, lol.
Best of luck in building your flows!
Hi,
How do I filter 2 values from the same column using ‘eq’ or ‘ne’?
Sandeep,
Like this:
myColumnName eq ‘one’ or myColumnName eq ‘two’
Is it possible double text condition ?
Hello. Is it possible to apply two different filters? I didn’t find the information yet. Thanks for your support.
Seb,
Yes, you can write an AND operator like this:
Customer eq ‘Friendly Farms’ and Amount eq 1000
Hi! I’m having trouble on the filter array step and receive the error, “The template language function ‘greater’ expects all of its parameters to be either integer or decimal numbers. Found invalid parameter types: ‘Null’.” I don’t think I have any nulls in my data set but even if I use an IF statement to replace nulls with zeroes, I am getting a blank output array. Any ideas?
Hey Matthew, I’m working on a flow to move renewal information from an excel table into Planner when the list item is +120 days from expiration. I am having a devil of a time getting a filter to work properly due to the eq/ne/etc limitation – I keep getting ALL items intstead of the filtered. I attempted your method above for the ≥ and ≤ but I’m getting hung up. I’m trying to compare an Expiration_Date column with what would amount to a utcNow timestamp expression.
I got the “today” to work as far as I can tell because the output is giving me an integer. The Expiration_Date from my table isn’t cooperating for me though and I cant seem to get it to convert to an excel number once it is in the flow (ironically).
Can you give me some advice on this? Thanks!
In your examples where you used a Filter Array, how can you send the result to an Apply to each so that you can go one by one through the results and then do an action. When I have tried, the Apply to each action immediately errors. I have tried multiple entries into the “Select An Output From Previous Steps” and nothing seems to work. Thoughts?
Hello Matthew. is possible sort by Date column in List row present in a table ???