cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UsePowerBI
Post Prodigy
Post Prodigy

How to group Table.SelectRows criteria?

Hello

 

Can you tell me please the right syntax for the below?

 

#"Filtered Rows2" = Table.SelectRows(#"Filtered Rows1", each not Text.Contains([Metric], "something1") and not Text.Contains([Metric], "something2") or [Metric] >0)

 

Particularly, how can I group into parentheses?

Is it:

each not ([1]>0 and [1]>2) and not (...

or

each not ([1]>0 and not [1]>2) and not (...

or

each (not [1]>0 and not[1]>2) and (not ...

 

In summary, do we group the 'not' inside parentheses or outside? When do we repeat it? When do we 'cancel' it, i.e. when we start with a 'not' criteria and then want to include positive/'without not' criteria?

 

Thanks!

1 REPLY 1
BA_Pete
Super User
Super User

Hi @UsePowerBI ,

 

The parentheses control how you want conditions to be evaluated in relation to one another, so there is no 'right' placement, it depends entirely on what you are trying to achieve.

 

For example:

( [A] = 1 and [B] = 2 ) or [C] = 3

This reads as [A] AND [B] must BOTH meet their conditions OR [C] must meet its condition to give the required output

 

[A] = 1 and ( [B] = 2 or [C] = 3 )

This reads as [A] must meet its condition AND either [B] OR [C] must ALSO meet their condition to give the required output

 

Therefore there's no way of saying whether the syntax example you provided is 'right', as we don't know what your expected/desired result from this filter is.

 

Regarding the 'not' operator - this reverses the evaluation of the function immediately following it, therefore should be included within any parentheses that encapsulate the relevant function.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors
Top Kudoed Authors