Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
My datatable is organised as in the image above and i would like to calculate for each country the difference from the previous date. How is this possible to do?
Solved! Go to Solution.
In DAX you can’t reference the previous row in any way because there is no order to the rows, So if you need to get previous row, you can create a rank column, and then use LOOKUPVALUE function to get it.
Rank = RANKX ( FILTER ( Table1, Table1[Country] = EARLIER ( Table1[Country] ) ), Table1[Date], , ASC )
PreviousScore = LOOKUPVALUE ( Table1[Score], Table1[Country], Table1[Country], Table1[Rank], Table1[Rank] - 1 )
Regards,
Charlie Liao
In DAX you can’t reference the previous row in any way because there is no order to the rows, So if you need to get previous row, you can create a rank column, and then use LOOKUPVALUE function to get it.
Rank = RANKX ( FILTER ( Table1, Table1[Country] = EARLIER ( Table1[Country] ) ), Table1[Date], , ASC )
PreviousScore = LOOKUPVALUE ( Table1[Score], Table1[Country], Table1[Country], Table1[Rank], Table1[Rank] - 1 )
Regards,
Charlie Liao
@v-caliao-msftthank you so much for your help. It worked perfectly and is so awesome.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.