Forum Discussion
How to dynamically calculate the cost difference between two dates per item?
- Anonymous4 years ago
Hi powerjey ,
Here are the steps you can follow:
1. Create measure.
Measure = var _min=MINX(ALLSELECTED('Table'),[Date]) var _max=MAXX(ALLSELECTED('Table'),[Date]) return SUMX(FILTER(ALL('Table'),'Table'[Date]=_max&&'Table'[Part#]=MAX('Table'[Part#])),[Price]) - SUMX(FILTER(ALL('Table'),'Table'[Date]=_min&&'Table'[Part#]=MAX('Table'[Part#])),[Price])2. Result:
If you need pbix, please click here.
How to dynamically calculate the cost difference between two dates per item.pbix
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi powerjey ,
Here are the steps you can follow:
1. Create measure.
Measure =
var _min=MINX(ALLSELECTED('Table'),[Date])
var _max=MAXX(ALLSELECTED('Table'),[Date])
return
SUMX(FILTER(ALL('Table'),'Table'[Date]=_max&&'Table'[Part#]=MAX('Table'[Part#])),[Price])
-
SUMX(FILTER(ALL('Table'),'Table'[Date]=_min&&'Table'[Part#]=MAX('Table'[Part#])),[Price])
2. Result:
If you need pbix, please click here.
How to dynamically calculate the cost difference between two dates per item.pbix
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks so much! Works perfectly.
I've learned alot from this post.
- lou_powerbi3 years agoRegular Visitor
In my case I have used your guidance to fix my issue.. Thanks a lot
% new perc =var w_previous = MINX(ALLSELECTED('DP Fcast (2)'),[Week_final])var w_current = MAXX(ALLSELECTED('DP Fcast (2)'),[Week_final])var diff1 = SUMX(FILTER(ALL('DP Fcast (2)'),'DP Fcast (2)'[Week_final]= w_current&&'DP Fcast (2)'[Location]=MAX('DP Fcast (2)'[Location])),[Fcast Volume(in EA) by Location])var diff2 = SUMX(FILTER(ALL('DP Fcast (2)'),'DP Fcast (2)'[Week_final]= w_previous&&'DP Fcast (2)'[Location]=MAX('DP Fcast (2)'[Location])),[Fcast Volume(in EA) by Location])var diff = diff1 - diff2var total = (diff1 + diff2) / 2var diff_perc = diff / totalvar result = diff_percreturn result