Forum Discussion

DonnaDonut85's avatar
DonnaDonut85
Frequent Visitor
5 years ago
Solved

Calculate difference from previous 'row'

Hi guys,

 

Hoping you can help. 

 

We have a requirement to report on the difference in days between the previous value. I have the Date, Project Number, Total Days and i now need the difference from the previous row. I have added and index and index.1 column thinking i could then use them to calculate, it's almost there but as you can see from the screenshot it's not quite right as it has the negative next to it, i'll be using this on a line graph so i just need the positive value. 

 

 

The calculation i have is 

Difference_ = 'ProjectStats'[TotalDays_]-CALCULATE(SUM('ProjectStats'[TotalDays_]),FILTER('ProjectStats','ProjectStats'[Moving Index.1]=EARLIER('ProjectStats'[Moving Index])))

 

Thanks! 

 

 

 

  • DonnaDonut85 , Try a new column lik

     

    New column =
    var _max = maxx(filter('ProjectStats', [requested_date]< earlier([requested_date])),[requested_date])
    return
    [TotalDays_] - maxx(filter('ProjectStats', [requested_date]=_max),[requested_date])

2 Replies

  • DonnaDonut85 , Try a new column lik

     

    New column =
    var _max = maxx(filter('ProjectStats', [requested_date]< earlier([requested_date])),[requested_date])
    return
    [TotalDays_] - maxx(filter('ProjectStats', [requested_date]=_max),[requested_date])