Forum Discussion

learner03's avatar
learner03
Post Partisan
4 years ago
Solved

Cumulative difference

 

How can I get cumulative difference as below?

QtyCumulative difference
105-
111-6
2388
45-22
100-55
7624
4531
63-18
  • So, you need to just reverse the order Cumulative Difference =([Prev])-CALCULATE(sum('Cumulative Diff'[Qty])) here, right?

     

    >> Keep Calculate first 

     

    Regards,

    Ritesh

     

     

3 Replies

  • Hi ,akakapoor,

     

    NOTE: Add a custom index column first Creating an Index column using a Power Query - Power BI Docs

     

    Step 1 

    Prev = CALCULATE(sum('Cumulative Diff'[Qty]),

    FILTER(all('Cumulative Diff'),('Cumulative Diff'[Index.1]+1) =

    max('Cumulative Diff'[Index.1])))
     
    Step 2
     
    Cumulative Difference =([Prev])-CALCULATE(sum('Cumulative Diff'[Qty]))
     
    Last Step = /get the - at the top
    Final Output = IF(min('Cumulative Diff'[Index.1])=1,"-",'Cumulative Diff'[Cumu Diff]
     

     


     

     
    Regards,
    Ritesh
    Please mark the answer as a solution if it helps you so that it can help others as well
    • learner03's avatar
      learner03
      Post Partisan

      ribisht17 I tried with the above and I am getting below view as per my data-

       

      The dates are rolling14 days. This is giving me opposite output, example-Bins Count OUT were more than the previous day, so basically 22 more were completed than previous day, but this is showing -22.

      How can I make it Positive?

      • ribisht17's avatar
        ribisht17
        Super User

        So, you need to just reverse the order Cumulative Difference =([Prev])-CALCULATE(sum('Cumulative Diff'[Qty])) here, right?

         

        >> Keep Calculate first 

         

        Regards,

        Ritesh