cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
adavid999
Helper V
Helper V

dax filtering

Hello, please can someone explain why these two measures produce different results (something to do with the AND/OR but I don't understand why these would differ)? (I am reposting this as I made an error in my original post)

 

measure 1 check (no.) =
CALCULATE (
    COUNT ( fct_core[colour] ),
    fct_core[type] = 1
        || fct_core[type] = 2
        || fct_core[type] = 3
        && fct_core[colour] = 5
        || fct_core[colour] = 6
        || fct_core[colour] = 7
        || fct_core[colour] = 8
)

 

and:

 

measure 2 check (no.) =
CALCULATE (
    COUNT ( fct_core[colour] ),
    fct_core[type] >= 1
        && fct_core[type] <= 3
        && fct_core[colour] = 5
        || fct_core[colour] = 6
        || fct_core[colour] = 7
        || fct_core[colour] = 8
)

 

thanks,

A

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Suppose you have type 2 and color 4. Then measure 1 would count it but not measure 2.

 

Note that your logical combination

T1 || T2 || T3 && C5 || C6 || C7 || C8

is equivalent to

T1 || T2 || (T3 && C5) || C6 || C7 || C8

not as I think you intended

(T1 || T2 || T3) && (C5 || C6 || C7 || C8)

 

I'd rewrite the measure as

 

check (no.) =
CALCULATE (
    COUNT ( fct_core[colour] ),
    fct_core[type] IN { 1, 2, 3 },
    fct_core[colour] IN { 5, 6, 7, 8 }
)

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

Suppose you have type 2 and color 4. Then measure 1 would count it but not measure 2.

 

Note that your logical combination

T1 || T2 || T3 && C5 || C6 || C7 || C8

is equivalent to

T1 || T2 || (T3 && C5) || C6 || C7 || C8

not as I think you intended

(T1 || T2 || T3) && (C5 || C6 || C7 || C8)

 

I'd rewrite the measure as

 

check (no.) =
CALCULATE (
    COUNT ( fct_core[colour] ),
    fct_core[type] IN { 1, 2, 3 },
    fct_core[colour] IN { 5, 6, 7, 8 }
)

 

That is really helpful, thanks Alexis and for stackoverflow too!

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!