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
GSE
Resolver I
Resolver 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
Resolver I
Resolver 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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

"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 )
    )
)

 

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.