cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GSE
Helper I
Helper I

Summarize with AND/OR Filter

Hi all,

 

I am trying to use the sumx and then the summarize function on a table. However, I want to filter the table first. The data that meets the following criteria should be excluded.

 

1. dim_house_id = 8

2. dim_house_id = 12 AND dim_class_id = 4

 

Both dim tables (house and class) are in a 1-to-many relationship with the fact table. I'm not sure how to filter here.

 

SUMX(SUMMARIZE(FILTER(fact table, RELATED(dim_house_id) <> 8 || RELATED(dim_house_id) <> 12 && RELATED(dim_class_id) <> 4)...

 

It's not so much about the sumx or summarize function but I don't know how to set up the filter criteria.

 

Any help would be appreciated.

 

Thanks

1 ACCEPTED SOLUTION

"FILTER(fact table, RELATED(dim_house_id) <> 8 || ( RELATED(dim_house_id) <> 12 && RELATED(dim_class_id) <> 4 ) )"

This doesn't filter anything out much like (x <> 1 || x<>2) is true for any value of x. (You need to swap your && and || to get the proper De Morgan's law negation.)

I'd propose this as a more intuitive option:

 

FILTER (
    'fact table',
    NOT (
          RELATED ( dim_house[house_id] ) = 8  ||
        ( RELATED ( dim_house[house_id] ) = 12 && RELATED ( dim_class[class_id] ) = 4 )
    )
)

 

View solution in original post

3 REPLIES 3
GSE
Helper I
Helper I

@AlexisOlson thank you so much. This is a very good and intuitive solution!

Greg_Deckler
Super User
Super User

@GSE Try:

FILTER(fact table, RELATED(dim_house_id) <> 8 || ( RELATED(dim_house_id) <> 12 && RELATED(dim_class_id) <> 4 ) )


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

"FILTER(fact table, RELATED(dim_house_id) <> 8 || ( RELATED(dim_house_id) <> 12 && RELATED(dim_class_id) <> 4 ) )"

This doesn't filter anything out much like (x <> 1 || x<>2) is true for any value of x. (You need to swap your && and || to get the proper De Morgan's law negation.)

I'd propose this as a more intuitive option:

 

FILTER (
    'fact table',
    NOT (
          RELATED ( dim_house[house_id] ) = 8  ||
        ( RELATED ( dim_house[house_id] ) = 12 && RELATED ( dim_class[class_id] ) = 4 )
    )
)

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.