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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
misharaina
Advocate I
Advocate I

SUMX not working as expected

Hi, I am trying to display the "Row total of vol/mix impact" using sumx but the row total is always displayed as Zero. Out of the multiple versions displayed on the slicer, the user will select two versions to compare the metrics and calculate the vol/mix impact.
lets call the last version  "minversion" and the new version "maxversions". Here is the formula for getting the last and the new versions - 
--------------------------------------------------------------------
VAR MinVersion = // previous version
LOOKUPVALUE('Version (Control)'[Version], 'Version (Control)'[Version Sort],
CALCULATE(MIN('Version (Control)'[Version Sort]), ALLSELECTED('Version (Control)'[Version Sort]), ALLSELECTED('Version (Control)'[Version])))

VAR MaxVersion = // new version
LOOKUPVALUE('Version (Control)'[Version], 'Version (Control)'[Version Sort],
CALCULATE(MAX('Version (Control)'[Version Sort]), ALLSELECTED('Version (Control)'[Version Sort]), ALLSELECTED('Version (Control)'[Version])))

//Next, we determine the last version price and the new version price  using the formula below - 

 

VAR MinVersionVar1 = //P1
CALCULATE(
Price,
'Version (Control)'[Version]= MinVersion,
ALL('Version (Control)'[Version Sort])
)
VAR MaxVersionVar1 = // P2
CALCULATE(
Price,
'Version (Control)'[Version] = MaxVersion,
ALL('Version (Control)'[Version Sort])
)

//Now we calculate the minversion and maxversion weighted volume as below -
 
VAR MinVersionVar2 = //Vol1
CALCULATE(
Vol1/Calculate(Vol1,allselected()),
'Version (Control)'[Version]= MinVersion,
ALL('Version (Control)'[Version Sort])
)
VAR MaxVersionVar2 = //Vol2
CALCULATE(
Vol2/Calculate(Vol2,allselected()),
'Version (Control)'[Version] = MaxVersion,
ALL('Version (Control)'[Version Sort])
)
 
// Next we calculate the average Price for both versions
VAR MinVersionVar3 = //Average Price
CALCULATE(
Calculate(Price,allselected()),
'Version (Control)'[Version] = MinVersion,
ALL('Version (Control)'[Version Sort])
)
VAR MaxVersionVar3 = //Average Price
CALCULATE(
Calculate(Price,allselected()),
'Version (Control)'[Version] = MaxVersion,
ALL('Version (Control)'[Version Sort])
)
 
// The formula that we have for price volume mix is as follows -
VAR Result = 0.5*((MaxVersionVar1-MaxVersionVar3)+(MinVersionVar1-MaxVersionVar3))*(MaxVersionVar2 - MinVersionVar2)

// Here is where I am trying to return the final answer. At an individual product level, the variable "result" gives the correct answer but the row total is always 0. I want the row total to sum up all the vol/mix impact -
 
IF (HASONEVALUE('Product(Control)'[Product),result,
Sumx(VALUES('Product (Control)'[Product]),Result)))

-----------------------------------------------------------------------------------------------------------------
// Another thing to note here is that the price and volume tables are different than the product table.
We have a product table that is related to the price and volume table.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@misharaina , Are you only using Product in visual. If you are using more columns use summarize and add those too

 

example

sumx(Addcolumns(Summatize(Fact, Dim[Col1], Dim2[Col2]), "_1",[Measure]) , [_1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
misharaina
Advocate I
Advocate I

Hi Amit,

 

I am using a parameter.

So my code is - 

RETURN SWITCH(SELECTEDVALUE('Metric (Support)'[Select Metric]),
"Revenue ($M)", Result/10^6,
IF (HASONEVALUE('Parameter Table'[Fields]),result,
Sumx('Parameter', Result)))

Best

Misha

amitchandak
Super User
Super User

@misharaina , Are you only using Product in visual. If you are using more columns use summarize and add those too

 

example

sumx(Addcolumns(Summatize(Fact, Dim[Col1], Dim2[Col2]), "_1",[Measure]) , [_1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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