Forum Discussion
Calculate difference of % between two rows
Hello Community,
I tried to find through the forums a solution to my problem. So the "recovery Service Level" is a created measure that calculate the Lines Shipped cumulative divided by the Sum of the Lines Shipped (in total i have 26'303 Lines Shipped). The last column is a simple way to see how much % was added in comparison with the one below. But i am struggling to find a robust solution. Is there a way to create a measure (and not a column) to calculate it? How to create a measure that calculates the difference of % between two rows dynamically?
| Days Late | Lines Shipped | Recovery Service Level | % added |
| - | 23593 | 89.70% | |
| 1.00 | 412 | 91.26% | 1.57% |
| 2.00 | 175 | 91.93% | 0.67% |
| 3.00 | 176 | 92.60% | 0.67% |
| 4.00 | 159 | 93.20% | 0.60% |
Best Regards,
Marc Parker
4 Replies
- amitchandak
Super User
Anonymous , Difference between two rows can not be done. So we need to create a formula that takes care of that. Like row value is day or month, we create prior day/month and take diff
- v-juanli-msft
Community Support
Hi Anonymous
Create measures
Recovery Service Level% = VAR total = 26303 RETURN CALCULATE ( SUM ( 'Table'[Lines Shipped] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Days Late] <= MAX ( 'Table'[Days Late] ) ) ) / total added = VAR total = 26303 RETURN IF ( MAX ( [Days Late] ) <> 0, CALCULATE ( SUM ( 'Table'[Lines Shipped] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Days Late] = MAX ( 'Table'[Days Late] ) ) ) / total )Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Thank you very much Maggie, it seems to work indeed. What if i wanted a dynamic calculation that would change the amount of lines Shipped ? Dynamic with the slicer i want to apply?
Best regards,
Marc
- AnonymousNot applicable
Hi Anonymous ,
If you are looking for calculating the Service Line Added, you can simply use the below measure.
Service Line added = DIVIDE ( SUM ( 'Table' [Lines Shipped])) , 26303)
You do not need to find the row difference in this case.
Mathematical function, you are Calculating [(23593+412)/26303] - (23593/26303) . This translates to 412/26303.
Hope I was able to explain this.
Attaching an excel screenshot for the same.
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!