Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ERing
Post Partisan
Post Partisan

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 of my measures below is correct. They both produce the same result.

Can anyone tell me which is correct?

SAMPLE FILE 

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"
)
)

 

1 ACCEPTED SOLUTION
hnguy71
Super User
Super User

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.



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

4 REPLIES 4
v-tsaipranay
Community Support
Community Support

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

hnguy71
Super User
Super User

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.



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
ExcelMonke
Super User
Super User

Hello,

Whilst they are both producing the same result, I would go with the latter formula. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.