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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
mukhan169
Helper III
Helper III

SUMX not calculating correct value for one month

I have a measure that calculates the average if only one value is selected from the drop down. if there are multiple values selected then calculate the average for each department individually and then add them together.

Following is the measure

Sum of Averge for past month =
 
var SimpleAverage= calculate (
AVERAGE(vwPowerBiData[ValueInUSD]),
FILTER(vwPowerBiData,vwPowerBiData[IsCurrentMonth]=False && vwPowerBiData[LineItemId]=1)

 
)
return
if(HASONEVALUE(vwDivision[Duns]),
SimpleAverage,
sumx(VALUES(vwPowerBiData[DivisionName]),SimpleAverage)
 
)
It calulates sum correctly for Jan, Feb and March 
JanuaryJanuaryCapture1.PNG
But when I try and do it in April the sum is I am not correct I cant even figure out what and how it is calculating
Capture2.PNG
it should be 2537. 
I am not sure what to do. Any help will be greatly appriciated.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

[Your Measure] =
SUMX (
	VALUES ( vwPowerBiData[DivisionName] ),
	CALCULATE (
		AVERAGE ( vwPowerBiData[ValueInUSD] ),
		KEEPFILTERS(
			NOT( vwPowerBiData[IsCurrentMonth] )
		),
		KEEPFILTERS(
			vwPowerBiData[LineItemId] = 1
		)
    )
)

 

I'd kindly suggest you learn how to build correct models using star schemas and how DAX works. Without this knowledge, you'll be creating measures that you'll not understand and which will return incorrect values without you even noticing it. Your model is technically feasible but it's bad. Good models follow the principles of DIMENSIONAL DESIGN. And in DAX VARiables are... well, constant, so you can't change them once they've been declared.

 

Best

D

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

[Your Measure] =
SUMX (
	VALUES ( vwPowerBiData[DivisionName] ),
	CALCULATE (
		AVERAGE ( vwPowerBiData[ValueInUSD] ),
		KEEPFILTERS(
			NOT( vwPowerBiData[IsCurrentMonth] )
		),
		KEEPFILTERS(
			vwPowerBiData[LineItemId] = 1
		)
    )
)

 

I'd kindly suggest you learn how to build correct models using star schemas and how DAX works. Without this knowledge, you'll be creating measures that you'll not understand and which will return incorrect values without you even noticing it. Your model is technically feasible but it's bad. Good models follow the principles of DIMENSIONAL DESIGN. And in DAX VARiables are... well, constant, so you can't change them once they've been declared.

 

Best

D

Thank you. I cant thank you enough. I just couldnt understand why/how it would calculate properly for 3 months but then move to different one in the last one. But again thank you.

AlexisOlson
Super User
Super User

It's not clear everything that's going wrong here but this line is not doing what you think it is:

 

sumx(VALUES(vwPowerBiData[DivisionName]),SimpleAverage)

 

When you define a variable, it's treated as a constant when you reference it later. To calculate it differently for different DivisionNames, you'll need to make SimpleAverage a measure instead of a constant VAR. 

I wish there was a way to "debug" the dax queries so I dont have to spent 6 hours on this thing.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.