Forum Discussion
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
- Greg_DecklerCommunity Champion
You want EARLIER. See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586
- Greg_DecklerCommunity Champion
You want EARLIER. See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586
- v-danhe-msftMicrosoft Employee
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
- v-danhe-msftMicrosoft Employee
Hi Anonymous,
Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered to close this topic?
Regards,
Daniel He