Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors