Friday, March 22, 2019

How to get the Previous Row value from a Column in Power BI

How to return Previous Row value from a Column in Power BI
Scenario:
Suppose we have a Same data as follows..

From this data, column "TotalUnits", we wants generate new calculated column to show the same TotalUnits but the each row value should get from the Previous Row value.

This can be in one of the way, by creating a Index Column on this Table.
The Index Column can be created from Home> Edit Queries > Add Column > Index Column

Next based on this Index Column, we will create a new Calculated Column "PrevRowUnits",
that shows the TotalUnits values that get from the Previous Rows, using the below DAX Expression :
PrevRowUnits = LOOKUPVALUE('Sample'[TotalUnits],'Sample'[Index],'Sample'[Index]-1)+0

Finally the Result is as follows :

Note:
The above Scenario may not be a best example, but you can relate it to your own Scenario.

-------------------------------------------------------------------------------------------------------- 
Thanks, TAMATAM ; Business Intelligence & Analytics Professional 
--------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.