Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I need to calculate the Jobs_Ran with the three following conditions:
'Table_A'[Training_Complete] = "Y",
'Table_A'[Senior_Advisor] = "Y",
Jobs_Ran_1 =
CALCULATE(
SUM(Table_A[Jobs_Ran]),
'Table_A'[Training_Complete] = "Y",
'Table_A'[Senior_Advisor] = "Y",
'Table_A'[Tenured_Employee] = "Y"
)
Jobs_Ran_2 =
CALCULATE(
SUM(Table_A[Jobs_Ran]),
FILTER('Table_A',
'Table_A'[Training_Complete] = "Y"
&& 'Table_A'[Senior_Advisor] = "Y"
&& 'Table_A'[Tenured_Employee] = "Y"
)
)
Solved! Go to Solution.
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.
Hi @ERing ,
Thank you for reaching out to the Microsoft fabric community forum. Also thank you for the detailed explanation provided by @hnguy71 which correctly highlights the key differences between these approache.
Using direct filter conditions within CALCULATE (as in your first measure) is generally more performant because it targets only the specific columns involved, whereas wrapping your conditions inside a FILTER() function iterates over the entire table row-by-row, which can be less efficient, especially with large datasets.
Therefore, unless you have a particular need for row-by-row evaluation or more complex filtering logic, the first measure using direct filters in CALCULATE is typically the recommended and more efficient approach.
I hope this will help you understand, if you need any further assistance, feel free to reach out.
If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.
Thankyou.
Hi @ERing ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you
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.
Hello,
Whilst they are both producing the same result, I would go with the latter formula.
Proud to be a Super User! | |
User | Count |
---|---|
84 | |
80 | |
69 | |
46 | |
46 |
User | Count |
---|---|
106 | |
45 | |
42 | |
39 | |
39 |