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
Anonymous
Not applicable

Total not showing - SUMX ISSUE

Hi,

I'm a little rusty on DAX and I need your help.

 

The result of the measure is on this table:

table.PNG
The measure:

WAP_AWAP_BWAP 2 = 
//WAP calculation
var salesValue = CALCULATE(SUM(FACT_SALES_DATA[VALUE]))
var salesVolume = CALCULATE(SUM(FACT_SALES_DATA[DEMAND]))
var PricePer10Sticks = (DIVIDE(salesValue, salesVolume)*[Pack_Size])*10
var TotalsalesValue = CALCULATE(SUM(FACT_SALES_DATA[VALUE]), ALL(DASH_PRODUCT[FINAL_SKU_NAME]))
var TotalsalesVolume = CALCULATE(SUM(FACT_SALES_DATA[DEMAND]), ALL(DASH_PRODUCT[FINAL_SKU_NAME]))
var WAP = (DIVIDE(TotalsalesValue, TotalsalesVolume)*[Pack_Size])*10

//AWAP calculation
var salesValueAboveWAP = CALCULATE(SUM(FACT_SALES_DATA[VALUE]), FILTER(FACT_SALES_DATA, PricePer10Sticks > WAP))
var salesVolumeAboveWAP = CALCULATE(SUM(FACT_SALES_DATA[DEMAND]), FILTER(FACT_SALES_DATA, PricePer10Sticks > WAP))
var AWAP = (DIVIDE(salesValueAboveWAP, salesVolumeAboveWAP)*[Pack_Size])*10

//BWAP calculation
var salesValueBelowWAP = IF(ISBLANK((CALCULATE(SUM(FACT_SALES_DATA[VALUE]), FILTER(FACT_SALES_DATA, PricePer10Sticks < WAP)))),0,CALCULATE(SUM(FACT_SALES_DATA[VALUE]), FILTER(FACT_SALES_DATA, PricePer10Sticks < WAP)))
var salesVolumeBelowWAP = CALCULATE(SUM(FACT_SALES_DATA[DEMAND]), FILTER(FACT_SALES_DATA, PricePer10Sticks < WAP))
var BWAP =IF(ISBLANK((DIVIDE(salesValueBelowWAP, salesVolumeBelowWAP)*[Pack_Size])*10),0,(DIVIDE(salesValueBelowWAP, salesVolumeBelowWAP)*[Pack_Size])*10)

VAR AAA=SUMX(FILTER(FACT_SALES_DATA,PricePer10Sticks<WAP),FACT_SALES_DATA[VALUE])


RETURN
AAA


What changes do I need in the measure to have total as 39.771.436?

I tried SUMMARIZE and after SUMX but without any result.

 

Thank you!

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi  @Anonymous ,

You can create another new measure as below base on the measure [WAP_AWAP_BWAP 2] to get the correct total value and put this new measure to replace the original measure [WAP_AWAP_BWAP 2] onto the visual:

Measure = SUMX ( VALUES ( DASH_PRODUCT[FINAL_SKU_NAME] ), [WAP_AWAP_BWAP 2] )

yingyinr_0-1651806117022.png

In addition, you can refer the method in the following links to resolve it.

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Dax for Power BI: Fixing Incorrect Measure Totals

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi  @Anonymous ,

You can create another new measure as below base on the measure [WAP_AWAP_BWAP 2] to get the correct total value and put this new measure to replace the original measure [WAP_AWAP_BWAP 2] onto the visual:

Measure = SUMX ( VALUES ( DASH_PRODUCT[FINAL_SKU_NAME] ), [WAP_AWAP_BWAP 2] )

yingyinr_0-1651806117022.png

In addition, you can refer the method in the following links to resolve it.

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Dax for Power BI: Fixing Incorrect Measure Totals

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
lbendlin
Super User
Super User

Your SUMX needs to be over the enumeration of FINAL_SKU_NAME.  Think of the column total as a separate table.

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.