Forum Discussion

zawlh's avatar
zawlh
Helper I
4 years ago
Solved

Calculating Daily values from Cumulative Total

I have a data table with Date and Total Values for each date. But these values is not for each update. These values are total value containing previous values: like for data 3, the value is for Day1+...
  • AlexisOlson's avatar
    AlexisOlson
    4 years ago

    Your example starts here:

     

    I'll add a new index column [Index1] = [Index] + 1 and then self merge:

     

    Expand Total_Values

     

    Define a new [Daily_Values] column as the difference between the total and the previous total.

     

    Result:

     

     

     




    File attached.

  • Ashish_Mathur's avatar
    Ashish_Mathur
    4 years ago

    Hi,

    This calculated column formula works

    Daily value = [Total_Values]-lookupvalue(RunningTotal[Total_Values],RunningTotal[Date],CALCULATE(max(RunningTotal[Date]),FILTER(RunningTotal,RunningTotal[Date]<EARLIER(RunningTotal[Date]))))

    Hope this helps.

  • Kumail's avatar
    Kumail
    4 years ago

    Hello zawlh 

     

    The image and DAX code are given below for your quick reference.

     

     

    DailyValue2 = 
    [DailyValue] - CALCULATE(MAX(RunningTotal[Total_Values]), FILTER(ALL(RunningTotal[Date]), RunningTotal[Date] < MAX(RunningTotal[Date])))

     

     

    Url to the pbix file https://drive.google.com/file/d/1pKkRWxJI56oKT2MeLsPKfF-tldwPlMzK/view?usp=sharing

     

    Regards

    Kumail Raza

    LinkedIn: https://www.linkedin.com/in/kumail-raza-76508856/

    If this answers your query, mark it as the solution.

    Kudos are appreciated.

  • v-yanjiang-msft's avatar
    4 years ago

    Hi zawlh ,

    According to your description, here’s my solution.

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.