Search code examples
filterpowerbidaxpowerbi-desktopmeasure

Difference betweeen filter and equal in a measure


I can't figure out the difference between the 2 following measures, returning the same result ?

TestFIlter = 
CALCULATE(
    SUM(BDD_Index[Conso]),
    FILTER(
        Plan_comptage_EDV,
        Plan_comptage_EDV[Plan CPT] = 1
    )
)

and

TestEQUAL = 
CALCULATE(
    SUM(BDD_Index[Conso]),
    Plan_comptage_EDV[Plan CPT] = 1
)

Which is the better one ? Any performance impact ? Thanks in advance.


Solution

  • The second is the better one. The first filters an entire table which is bad practice (you should only filter columns). The second is syntax sugar and internally rewritten as:

    TestEQUAL = 
    CALCULATE(
        SUM(BDD_Index[Conso]),
        FILTER(
            ALL(Plan_comptage_EDV[Plan CPT]),
            Plan_comptage_EDV[Plan CPT] = 1
        )
    )
    

    Further reading:

    https://www.sqlbi.com/articles/filter-arguments-in-calculate/

    https://www.youtube.com/watch?v=Tk-7gBt9CDE&list=RDCMUCcc21gBGNJwZM_eDEByeN-Q&index=4