Forum Discussion
How to do calculations at row level using Dax Measures
I want to calculate variance or do some other calculations at the row level. Mainly using Dax Measures.
How to do it?
Please help
Hi Anonymous ,
If you want to calculate the difference between the next row data and the current row data, we can create two calculate columns to meet your requirement.
1. Create an index column in Power Query Editor.
2. Then we can create two calculate columns,
Variance No.s = CALCULATE(SUM('Table'[Data]),FILTER('Table','Table'[Index]>EARLIER('Table'[Index]))) - 'Table'[Data]Variance % = var _next_row = CALCULATE(SUM('Table'[Data]),FILTER('Table','Table'[Index]>EARLIER('Table'[Index]))) return DIVIDE('Table'[Variance No.s],_next_row)If it doesn't meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 Replies
- nvprasad
Solution Sage
HI,
All the "X" ended functions like Sumx, Countx, Maxx, ...etc are row level iterators. You can use them in measures.
Thank You,
Regards,
Venkat Nalla
- AnonymousNot applicable
Can you please provide a demo or screenshots for a better understanding?
It will be a big help.
Regards
- amitchandak
Super User
Anonymous , Not sure whom you have asked. But please find the attached file .
Search for Gross sales and Gorss Sales Measure an check page 7.
Also, refer
- amitchandak
Super User
Anonymous , Use X measures like Sumx, Minx, Maxx, Countx
Like measure is same as
New Gross Sales= sumx(Sales, Sales[Qty]*Sales[Price])
The column
New Column = Sales[Qty]*Sales[Price]
New Measure = sum(Table[New column])
New Measure and New Gross Sales measures are the same