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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PBInterest
Frequent Visitor

Question about when to SUM values in a measures vs. SUM of two measures

Lets say I have two values, SalesAmount and DiscountAmount. SalesAmount minus the DiscountAmount is the NetSaleAmount.

 

I can create a measure something like: NetSaleAmount = (SUM(SalesAmount) - SUM(DiscountAmount).

 

or

 

I can create two measures, one for SalesAmount and one for DiscountAmount and do something like: NetSalesAmount = [SalesAmount] - [DiscountAmount]?

 

If I have to use the NetSalesAmount result in other measures in my model which way is better for overall performance in the model? 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@PBInterest There shouldn't be any real performance difference I would not think as either way DAX should essentially produce the same end query. You can check this using DAX Studio or by using the Performance Analyzer and copying the DAX query produced and comparing.

 

Really, boils down to a preference and if you need to use Sales Amount and Discount Amount in other measures. Many people advocate for creating simple aggregation measures for base value columns and then hiding the columns and only exposing the measures. The downside to this is that if you need a bunch of different aggregations, SUM, AVERAGE, MAX, MIN, etc. you can end up with a lot of base measures which might create confusion.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@PBInterest There shouldn't be any real performance difference I would not think as either way DAX should essentially produce the same end query. You can check this using DAX Studio or by using the Performance Analyzer and copying the DAX query produced and comparing.

 

Really, boils down to a preference and if you need to use Sales Amount and Discount Amount in other measures. Many people advocate for creating simple aggregation measures for base value columns and then hiding the columns and only exposing the measures. The downside to this is that if you need a bunch of different aggregations, SUM, AVERAGE, MAX, MIN, etc. you can end up with a lot of base measures which might create confusion.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

That's helpful, thanks for the reply.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors