adame
adame

Reputation: 137

dax filters producing different results

please can you let me know why these two measures produce different results? I am obv missing something simple to do with AND and OR. thank you.

measure 1 = 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
)

measure 2 = 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
)

Upvotes: 0

Views: 40

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40204

This is an order of operations misunderstanding.

If you put in appropriate parentheses, then these measures should be the same (assuming types only have integer values).

measure 1 =
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
    )
)

measure 2 =
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
    )
)

Upvotes: 1

Related Questions