Difference between two rows in Power BI
Hello friends! today we’ll be learning how to calculate difference between two rows from same columns in Power BI. Easy to follow tutorial and reusable Power BI file is uploaded to GitHub repository
Recently I got the requirement to calculate the daily sales in Power BI whereas the data contained the cumulative sales on daily basis.
Data was in the following structure
Date | Cumulative Sales |
9/17/2021 | 40 |
9/18/2021 | 69 |
9/19/2021 | 108 |
9/20/2021 | 147 |
9/21/2021 | 168 |
9/22/2021 | 205 |
9/23/2021 | 228 |
9/24/2021 | 254 |
9/25/2021 | 269 |
9/26/2021 | 294 |
9/27/2021 | 316 |
Step 1 – Sort the data based on date column
Step 2 – Add the index 2 index columns From 0 and From 1 both as shown in the image below
Once the index columns added it will look something like below.
Step 3 – Merge table to self with Index columns. Select Index 0 column and Index.1 column and Left outer join as shown in the image below.
Step 4 – Creating a new column for daily sales as shown in the image below.
Keep visiting Analytics Tuts for more tutorials.
Thanks for reading! Comment your suggestions and queries
Hi,
I did follow step to subtract two row from same column. on step 3 Merge table option-not bale to see ok button highlighted.
Hi Can you attach the file or explain more?
I followed the step until step 3, but the step 4 is very confusing, you expanded the column, removed column, replaced value and added a custom column. Those are about 3 steps that you didn’t show. Could you explain further?
Hi Lola – Attaching the file here for your reference. Please reach out if still face issues.
Hi, I want to create a measure and calculate instead of creating new column. Please help me out
Lets connect over zoom call