Forum Discussion
Calculated measure that won't sum
Hi,
I have a question about a calculated measure that won't sum in a table.
The measure is
Good morning Anonymous
I can, yes.
Updated PBIX file available here: https://www.dropbox.com/s/eu9rx5206hqpddo/FreightForcast.pbix?dl=0
16 Replies
- MFelix
Super User
Hi Anonymous ,
Measures in DAX are calculated based on context so the columns, slicers, filters visuals interactions can change the calculation of a measure.
In your case since the total row doesn't have dateforec[date] associated with it, because it's an aggregation line the result is blank.
You need to redo your measure to have an aggregator for making the sum of the rows. Something similar to:
[FreightCost LY] = SUMX ( Dateforec; CALCULATE ( SUM ( transportorder[freightcost] ); DATEADD ( dateforec[date]; -12; MONTH ) ) )Be aware that this can change your final result also, without any sample data is difficult to give you a better answer.
If this measure doesn't work please share a sample of your model.
Regards,
MFelix
- AnonymousNot applicable
Hi,
Thank you for your reply, but this didn't solve the problem. My measure [Freightcost Forecast] still doesn't show a column total although I applied the changes to [FreightCost LY] as proposed. Actually, it didn't change the outcome of [FreightCost LY] either. What I want is that I only want [FreightCost Forecast] to show a value only in case [freightcost] is null (as for future dates), which works fine with the if statement in the measure formula. I think that the problem is that the measure gets caulcated as variant and data type variants don't sum in tables. I have tried to use value([Freight Cost Forecast]), but no change.
Henrik
MFelix wrote:Hi Anonymous ,
Measures in DAX are calculated based on context so the columns, slicers, filters visuals interactions can change the calculation of a measure.
In your case since the total row doesn't have dateforec[date] associated with it, because it's an aggregation line the result is blank.
You need to redo your measure to have an aggregator for making the sum of the rows. Something similar to:
[FreightCost LY] = SUMX ( Dateforec; CALCULATE ( SUM ( transportorder[freightcost] ); DATEADD ( dateforec[date]; -12; MONTH ) ) )Be aware that this can change your final result also, without any sample data is difficult to give you a better answer.
If this measure doesn't work please share a sample of your model.
Regards,
MFelix
Henrik
- MFelix
Super User
Hi Anonymous ,
As I refer measures and calculations are based in context so the way you setup the tables and the measure will alter the final result.
Can you share a sample model or a mockup with expected result so I can check what has to be changed?
Regards,
MFelix