Forum Discussion

ERing's avatar
ERing
Icon for Post Partisan rankPost Partisan
1 year ago
Solved

Which measure using Calculate is correct?

I need to calculate the Jobs_Ran with the three following conditions: 'Table_A'[Training_Complete] = "Y", 'Table_A'[Senior_Advisor] = "Y", 'Table_A'[Tenured_Employee] = "Y" I'm not sure which ...
  • hnguy71's avatar
    1 year ago

    Hi ERing,

    They would both produce the same result however Jobs_Ran_1 would be more performant. And, I'll tell you why (at least from my understanding).

     

    With CALCULATE, you have three primary modifiers to choose from. FILTER, KEEPFILTERS, and CALCULATE, itself. FILTER is the slowest and should only be used when absolutely necessary.

     

    When using FILTER, it accepts a table as its first argument. It then commits your entire table into evaluation regardless if the columns are being used. Imagine a table with 20+ columns and millions of rows. This has a huge cost to large datasets. Additionally, when using FILTER it replaces or strips any filter context on the table.

     

    When using KEEPFILTERS, it is a more efficient modifier. The function accepts a single column and does preserve any existing filters applied on the table.

    Finally, using just CALCULATE without any additional modifiers is typically the same thing as using KEEPFILTERS. There is one thing to keep in mind though is that although CALCULATE and KEEPFILTERS are similar, they often time yields different results.

     

    Anyhow, back to your two versions, using only CALCULATE evaluates only those three specific columns rather than the entire table making it more performant.