Forum Discussion
Totals incorrect for visual level calculation
- Anonymous2 years ago
Hi,TrevLc
Thank you for your replay
If you have more than one product and are calculating the difference between the current day's and previous day's quantities for each product on a row-by-row basis, and ultimately returning the correct sum of the differences, you can refer to the test I've done below
Here is my test result:Versus previous = VAR prev=IF([Product]=PREVIOUS([Product]), [M_Amount_value] - PREVIOUS([M_Amount_value]), [M_Amount_value]) VAR differ= SUMX(VALUES([Date]), CALCULATE(prev) ) return IF(ISINSCOPE([Date]), differ, [Sum of C_Difference_3] )C_Difference_3 = VAR CurrentValue=[Amount] VAR PreviousValue = CALCULATE( MAX('Table2'[Amount]), FILTER( ALL('Table2'), 'Table2'[Product] = EARLIER('Table2'[Product]) && 'Table2'[Date] < EARLIER('Table2'[Date]) ) ) RETURN CurrentValue -PreviousValueHere is my test data:
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
TrevLc , I doubt as of now you can use previous values in GT.
You can log an Idea of Issue
https://community.powerbi.com/t5/Issues/idb-p/Issues
- TrevLc2 years ago
Helper III
Thanks for your response.
Do you know a way I can sum the line items for the visual level calculation?