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
ecarg_124
Helper I
Helper I

Incorrect Totals for more complex calculations

Hi All,

 

I am new to Power BI and DAX so would appreciate any help I can get. I working on mix analysis and I am having troubles getting the correct the sum total. I've seen some posts regarding the usage of SUMX, but i couldn't get it to work. Hoping to get some support from the experts in this community! Appreciate it! 

 

Raw data looks like this:

REGIONSEGMENTSKUVOLUME BUDGETVOLUMENET REVENUE BUDGETNET REVENUE
Region1Segment1Sku1    
Region1Segment1Sku2    
Region1Segment1Sku3    
Region1Segment1Sku4    
Region1Segment2Sku1    
Region1Segment2Sku2    
Region1Segment2Sku3    
Region1Segment2Sku4    
Region2Segment1Sku1    
Region2Segment1Sku2    
Region2Segment1Sku3    
Region2Segment1Sku4    
Region2Segment2Sku1    
Region2Segment2Sku2    
Region2Segment2Sku3    
Region2Segment2Sku4    
  TOTAL    

 

This is how I would like to see the output:

 Segment Mix
Region1 
  Segment1 
  Segment2 
Region2 
  Segment1 
  Segment2 
Total 

 

Segment Mix = ( ([VOL]/[VOL (Total Region)]) - ([BU VOL]/[BU VOL (Total Region)]) ) *
([NR/unit] - ([NR (Total Region)]/[VOL (Total Region)])) *
([BU VOL (Total Region)]/[BU VOL (All Regions)])

 

The segment mix measure works for each line except for the TOTAL. For the Total, i need the sum of the segment mix for each line. 

 

Here are other measures used:

VOL= sum(DATA[VOLUME])

VOL (Total Region) = CALCULATE([VOL],ALL(PRODUCT_LOOKUP[SEGMENT]))

BU VOL= sum(DATA[VOLUME BUDGET])

BU VOL (Total Region) = CALCULATE([BU VOL],ALL(PRODUCT_LOOKUP[SEGMENT]))

BU VOL (All Regions) = CALCULATE([BU VOL],ALL(REGION_LOOKUP[REGION]),ALL(PRODUCT_LOOKUP[SEGMENT]),ALL(PRODUCT_LOOKUP[SKU]))

NR=sum(DATA[NET REVENUE])

NR/unit = NR / VOL

NR (Total Region) = CALCULATE([NR],all(PRODUCT_LOOKUP[SEGMENT]))

 

Thank you all!

 

3 REPLIES 3
amitchandak
Super User
Super User

@ecarg_124 

Divide work best when you sum(A)/Sum(B). Multiplication works best when you have Sum(A*B)

In you case it Sum(A)*Sum(B). In this case you have to use Summarize or values to have multiplication context  and sum and Avg after that

Something like this

sumx(Summmarize(Dim[Date1],"M1",[measure1],"M2",[Measure2]),[M1]*[M2])

Thanks for the quick response! I think i came across another issue with the Summarize function this time, which is affecting the overall SUMX results. 

 

As part of my formula, I need to include the SALES TOTAL REGION number. This is what I am getting when I do a simple matrix & measure. The values here are correct.

 

MATRIX RESULTS 
   
REGIONSALESSALES TOTAL REGION
REGION120,000105,500
REGION250,000105,500
REGION335,500105,500
TOTAL105,500105,500

SALES = sum(Actual Sales)

SALES TOTAL REGION = CALCULATE (sum(Actual Sales), ALL(DATA [REGION]), ALL (DATA [SEGMENT]), ALL(DATA [SKU]))

 

However, when I create a Table using summary, this is what I am getting instead:

SUMMARIZE RESULTS 
   
REGIONSALES2SALES TOTAL REGION2
REGION120,00020,000
REGION250,00050,000
REGION335,50035,500
TOTAL105,500105,500

Table = SUMMARIZE ( DATA, DATA[REGION],

"SALES2", sum(Actual Sales),

"SALES TOTAL REGION2", CALCULATE (sum(Actual Sales), ALL(DATA [REGION]), ALL (DATA [SEGMENT]), ALL(DATA [SKU]))

 

Not sure what I am doing wrong. Thank you again for the help!

 

@amitchandak 

 

Thanks for the quick response! I think i came across another issue with the Summarize function this time, which is affecting the overall SUMX results. 

 

As part of my formula, I need to include the SALES TOTAL REGION number. This is what I am getting when I do a simple matrix & measure. The values here are correct.

 

MATRIX RESULTS 
   
REGIONSALESSALES TOTAL REGION
REGION120,000105,500
REGION250,000105,500
REGION335,500105,500
TOTAL105,500105,500

SALES = sum(Actual Sales)

SALES TOTAL REGION = CALCULATE (sum(Actual Sales), ALL(DATA [REGION]), ALL (DATA [SEGMENT]), ALL(DATA [SKU]))

 

However, when I create a Table using summary, this is what I am getting instead:

SUMMARIZE RESULTS 
   
REGIONSALES2SALES TOTAL REGION2
REGION120,00020,000
REGION250,00050,000
REGION335,50035,500
TOTAL105,500105,500

Table = SUMMARIZE ( DATA, DATA[REGION],

"SALES2", sum(Actual Sales),

"SALES TOTAL REGION2", CALCULATE (sum(Actual Sales), ALL(DATA [REGION]), ALL (DATA [SEGMENT]), ALL(DATA [SKU]))

 

Not sure what I am doing wrong. Thank you again for the help!

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.