cancel
Showing results for 
Search instead for 
Did you mean: 
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!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

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!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

View solution in original post

That's helpful, thanks for the reply.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.