Steps to Get Previous Row Value From Column | Deep Dive Into PowerBI
Steps to Get Previous Row Value From Column| Deep Dive Into PowerBI
The previous article of this series was about How to Calculate the Sum of Sales between Two Dates using New Measure. If you want to read the previous article click on the Link
In this article, we will learn how to get previous row value from the column and insert in the next row of different columns. This task will help you guys when we compare columns or row values for some specific operations.
Let's start
Firstly we look at our data, on which column, we performing this task. In this data we have a column name 'Sold Units', we perform an operation on it. I show you the data in the picture below.
We divide this operation into a two-step
- Step 1:- add a new index column, follow the below steps. This is very important because we using index value into the DAX function to perform this task.
Click on transform data, after that power query window is opened.
- Step 2:- Now it's time to create a custom column using LOOKUPVALUE DAX function.
Click on the 'custom column'. Custom column windows opened, Write your Dax function here.
DAX function
PrevRowUnit=LOOKUPVALUE([Units Sold],[Index.1],[Index.1]-1)+0
The custom column is finally created.
After completing all above step plot your data on table visual
You can see your task is completed.you can see dashboard look like