Forum Discussion
Power Query: Apply Filter Expression Only if Condition Met in Another Column
- 1 year ago
The next step is to rearrange the query so that the most frequently encountered condition is tested for first etc.
- 1 year ago
There turned out to be some unexpected instances of duplicatation where both range statements were true. (errors in the data) So the final version that worked was:
= Table.SelectRows(#"Expanded All", each [Column3] = 1 or [Column1] >= [Column4] and [Column1] <= [Column5] or not ([Column1] >= [Column4] and [Column1] <= [Column5]) and [Column2] >= [Column4] and [Column2] <= [Column5] )
lbendlin
Below was my prompt for ChatGPT. Maybe I explained what I want more clearly for AI, because I know how "artificial" it can be. 😄 Will your solution accomplish what I describe below?
I have the following expression to filter rows based on a column:
= Table.SelectRows(#"Expanded All", each ([Column1] >= [Column4] and [Column1] <= [Column5]) or ([Column2] >= [Column4] and [Column2] <= [Column5])
)
But I only want to apply the filter if a condition is met in a column currently not referenced in the expression. I want to keep all rows that do not meet the condition, and I want to apply the above filter only to rows that meet that contion.
This is the condition:
if [Column3] > 1
Is there a way to add this condition to the above expression to achieve my goal?