Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Bring previous data and calculate difference

Hi, I'm trying to do something like this

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When the identification matches, it brings the water level from the previous date and also in another column it makes the difference between the current water level and the previous water level.

 

I think it's something with the previous function and the filter, but I could not make it work

 

Any ideas?

Thank you!

  • Hi Anonymous,

    Based on my test, you could refer to below steps:

    Sample data:

    Create below calculated columns:

    Index = RANKX('Table1','Table1'[Date],,ASC,Dense)
    previous number = var a=[Index]-1
    return CALCULATE(SUM(Table1[Number]),FILTER('Table1','Table1'[Index]=a))
    Difference = IF(ISBLANK('Table1'[previous number]),BLANK(),[Number]-[previous number])

    Result:

    You could also download the pbix file to have a view.

     

    Regards,

    Daniel He

4 Replies