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 August 31st. Request your voucher.

Reply
JulienZH
Helper II
Helper II

Roll-Up total doesn't add up

Hi,

I'm having a hard time figuring out why my total doesn't add up. Would anyone be able to help me figure out how to fix it ?
The DAX for the total probably should have a different expression, hence the switch(), but I just don't know what would be correct.

 

JulienZH_0-1639126128724.png

JulienZH_1-1639126145365.png

 

Thanks!

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

 

Test = 
SUMX(
	VALUES( M_Countries[Country] ),
    
    VAR Growth_Rate =
    	CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="EFC1")
    	- CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC")
    
    VAR Assumed_Rate=
    	CALCULATE(SUM(EFC[Value]),EFC[KPI]="Assumed Rate", ALL('Axis'), 'Axis'[Period]="EFC1" )

    
    VAR OUE_over_NEP = 
    	DIVIDE(
    		CALCULATE(SUM(EFC[Value]),EFC[KPI]="OUE",ALL('Axis'), 'Axis'[Period]="FC" ),
    		CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC" )
    		,0)
    
    VAR OUE_pct_var = 
    	CALCULATE(SUM('Variable Costs'[% OUE]))

    VAR ULAE_over_NEP=
    	DIVIDE(
    		CALCULATE(SUM(EFC[Value]),EFC[KPI]="ULAE",ALL('Axis'), 'Axis'[Period]="FC" ),
    		CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC" )
    		,0)
    
    VAR ULAE_pct_var= CALCULATE(SUM('Variable Costs'[% ULAE]))

	RETURN
	
	IF (
		SELECTEDVALUE ( 'Axis'[Period] ) <> "EFC1",
		BLANK (),
		(Growth_Rate - Assumed_Rate) * (OUE_pct_var * OUE_over_NEP + ULAE_pct_var * ULAE_over_NEP)
	)
)

 


You'd closed the SUMX to early. Hope the above now works!



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

10 REPLIES 10
JulienZH
Helper II
Helper II

Thanks for the reply! Unfortunately still not adding up.

JulienZH_0-1639136613768.png

 

bcdobbs
Community Champion
Community Champion

Ignore request for PBIX File.

 

Try this:

 

 

SUMX(
	VALUES( M_Countries[Country] ),
	
	VAR = ....
	VAR = ....
	VAR = ....
	
	
	
	RETURN (Growth_Rate - Assumed_Rate) * (OUE_pct_var * OUE_over_NEP + ULAE_pct_var * ULAE_over_NEP)
	)

 


The VAR = bits is you existing code. I've just wrapped the whole thing in an iterator over countries.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

JulienZH_0-1639143229198.png

I hope I understood you well. If so, it still does not work.
I can t find a way to share the Power BI, the company is pretty strict. I'm waiting for an approval to share dummy data though.

bcdobbs
Community Champion
Community Champion

Not quite, you needed a single SUMX round the whole lot. If you paste just the DAX code in text form I'll edit and send back.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Hmm, I did try at first this way but DAX error

JulienZH_0-1639145272516.png



Here's the text:

Test = 
SUMX(VALUES( M_Countries[Country] ),
    VAR Growth_Rate=CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="EFC1")
    - CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC")
    VAR Assumed_Rate=CALCULATE(SUM(EFC[Value]),EFC[KPI]="Assumed Rate",ALL('Axis'), 'Axis'[Period]="EFC1" )

    VAR OUE_over_NEP= DIVIDE(CALCULATE(SUM(EFC[Value]),EFC[KPI]="OUE",ALL('Axis'), 'Axis'[Period]="FC" ),CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC" ),0)
    VAR OUE_pct_var= CALCULATE(SUM('Variable Costs'[% OUE]))

    VAR ULAE_over_NEP=DIVIDE(CALCULATE(SUM(EFC[Value]),EFC[KPI]="ULAE",ALL('Axis'), 'Axis'[Period]="FC" ),CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC" ),0)
    VAR ULAE_pct_var= CALCULATE(SUM('Variable Costs'[% ULAE]))
)
RETURN
IF (SELECTEDVALUE ( 'Axis'[Period] ) <> "EFC1",BLANK (),
(Growth_Rate - Assumed_Rate) * (OUE_pct_var * OUE_over_NEP + ULAE_pct_var * ULAE_over_NEP))
bcdobbs
Community Champion
Community Champion

 

Test = 
SUMX(
	VALUES( M_Countries[Country] ),
    
    VAR Growth_Rate =
    	CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="EFC1")
    	- CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC")
    
    VAR Assumed_Rate=
    	CALCULATE(SUM(EFC[Value]),EFC[KPI]="Assumed Rate", ALL('Axis'), 'Axis'[Period]="EFC1" )

    
    VAR OUE_over_NEP = 
    	DIVIDE(
    		CALCULATE(SUM(EFC[Value]),EFC[KPI]="OUE",ALL('Axis'), 'Axis'[Period]="FC" ),
    		CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC" )
    		,0)
    
    VAR OUE_pct_var = 
    	CALCULATE(SUM('Variable Costs'[% OUE]))

    VAR ULAE_over_NEP=
    	DIVIDE(
    		CALCULATE(SUM(EFC[Value]),EFC[KPI]="ULAE",ALL('Axis'), 'Axis'[Period]="FC" ),
    		CALCULATE(SUM(EFC[Value]),EFC[KPI]="NEP",ALL('Axis'), 'Axis'[Period]="FC" )
    		,0)
    
    VAR ULAE_pct_var= CALCULATE(SUM('Variable Costs'[% ULAE]))

	RETURN
	
	IF (
		SELECTEDVALUE ( 'Axis'[Period] ) <> "EFC1",
		BLANK (),
		(Growth_Rate - Assumed_Rate) * (OUE_pct_var * OUE_over_NEP + ULAE_pct_var * ULAE_over_NEP)
	)
)

 


You'd closed the SUMX to early. Hope the above now works!



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

THANK YOU ! 😍

bcdobbs
Community Champion
Community Champion

Are you able to supply a pbix file with some dummy data in it?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
bcdobbs
Community Champion
Community Champion

Replace the return with this:

RETURN

SUMX(
	M_Countries[Country],
	(Growth_Rate - Assumed_Rate) * (OUE_pct_var * OUE_over_NEP + ULAE_pct_var * ULAE_over_NEP)
	)
	

 

It forces the calculation to be done one country at the time and then adds the result.

 

Within a row there is only one country so you get the result back. In the total it adds up each country.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
bcdobbs
Community Champion
Community Champion

Sorry I missed a VALUES!
Should have read:

RETURN

SUMX(
	VALUES( M_Countries[Country] ),
	(Growth_Rate - Assumed_Rate) * (OUE_pct_var * OUE_over_NEP + ULAE_pct_var * ULAE_over_NEP)
	)





Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.