A Deep Dive into Power Automate Excel Filter Queries: Filtering Greater Than, Less Than, and Removing Blank Rows

I discovered that the “greater than or equal to” (ge) and “less than or equal to” (le) operators cannot be used in Excel filter queries, so I decided to investigate this in detail.

スポンサーリンク

Preparation

I used filter queries on this Excel file stored in OneDrive to thoroughly test their behavior.
Excel file on OneDrive used for filter query testing

Filtering Strings

A variety of operators are available for filtering string columns:

  • eq : equals
  • ne : not equal to
  • startswith : starts with
  • endswith : ends with
  • contains : contains
Both eq and ne can be used as expected.
Example: eq and ne operators in use
Filter query results for eq and ne
You can also use startswith and endswith.
Example: startswith operator
Example: endswith operator
The contains operator is also supported, making string filtering quite versatile.
Example: contains operator
Results for contains filter
ColumnName eq 'TargetString'           // equals
ColumnName ne 'TargetString'           // does not equal
startswith(ColumnName, 'TargetString') // starts with
endswith(ColumnName, 'TargetString')   // ends with
contains(ColumnName, 'TargetString')   // contains

Removing Blank Rows

If you want to remove rows where a certain column is blank, you can achieve this by combining the ne (not equal) operator with an empty string.
Using ne operator to filter out blank rows
Result showing filtered rows with no blanks
ColumnName ne ''    // Do not forget to use "''"

Filtering Numbers and Dates/DateTimes

For numbers and dates, you can filter using eq (equals) and ne (not equals) without any issues.
eq and ne operators for numbers and dates
Filter results with eq and ne
However, Excel filter queries do not support “greater than or equal to” or “less than or equal to” (ge, le). If you try to use these operators, an error occurs:
【Invalid filter clause: unsupported operation. Only single ‘eq’, ‘ne’, ‘contains’, ‘startswith’ or ‘endswith’ is currently supported.】
Invalid filter error for unsupported operators
Error message when using unsupported operators
So, if you want to perform these types of filters, you need to use an array filter after retrieving the data (for dates, it’s easier to work with the ISO 8601 format).
Example: Using an array filter for advanced filtering
For the left side of the condition, use the column value retrieved from Excel (item()[‘ColumnName’]), and for dates, align the format using formatDateTime.
Specifying the left value from Excel output
On the right side, specify the comparison value (number or date).
Specifying the right value for comparison
This enables the desired filtering.
Filter results after using array filtering

When You Want to Filter Large Amounts of Data Quickly

However, the above methods only filter the data after it has been retrieved, so you need to be aware of Excel’s maximum row retrieval limit of 256 rows.
If you want to filter large amounts of data quickly, it is recommended to use Office Scripts.

Related Articles

Copied title and URL