Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
bhuprakashs
Helper I
Helper I

Need row wise difference in table matrix

Hi Team,

I want to get row by row difference of value and want to show in table matrix. 

Input:

ProductBasicDeluxeEconomy
A465
B951
C817
D525
E1036


Output:

ProductBasicDeluxeEconomy
A465
B5-1-4
C-1-46
D-31-2
E511


if you see the output table,
For Product A Row , I am showing same value because it is first row so no value to subtract.

For Product B Row , I want Product B - Product A 
For Product C Row , I want Product C - Product  B and So on.

Kindly help me how can I achieve this ? thank you in advance. 





1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@bhuprakashs , Create a visual calculation like this and hide the original measure, assuming this a matrix. Else do for all three measures and hide original 

Calculation = if([Brand] ="Brand 1", [Net], [Net]- PREVIOUS([Net]))

 

amitchandak_0-1763651982530.png

Visual Calculations  RUNNINGSUM, RANGE, MOVINGAVERAGE, COLLAPSE, COLLAPSEALL, EXPAND, EXPANDALL, FIRST, LAST, PREVIOUS, and NEXT
https://www.youtube.com/watch?v=bKD9T0EWgQo&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
DataVitalizer
Solution Sage
Solution Sage

Hi @bhuprakashs 

I suggest following these steps inside Power Query to achieve your goal:

 

  • In Power Query, sort your table by Product.

  • Add an Index column starting at 0.

  • Duplicate the query as a reference, call it PrevTable. In PrevTable, add 1 to the Index (so row A=1, B=2, etc.).

  • Merge the original table with PrevTable on Index = Index+1.

  • Expand the merged columns (Basic, Deluxe, Economy) as previous values.

  • Add custom columns:

BasicDiff = if [PrevTable.Basic] = null then [Basic] else [Basic] - [PrevTable.Basic],
DeluxeDiff = if [PrevTable.Deluxe] = null then [Deluxe] else [Deluxe] - [PrevTable.Deluxe],
EconomyDiff = if [PrevTable.Economy] = null then [Economy] else [Economy] - [PrevTable.Economy]

 

Did it work? 👍 A kudos would be appreciated
🟨 Mark it as a solution to help spread knowledge 💡

 

🟩 Follow me on LinkedIn

@DataVitalizer thanks for the help. but I am using live connection as a data source so can not make changes in dataset. any way solution with DAX ?

@amitchandak , Thanks Amit . I am checking your solution but I do not want to keep original columns in the table. Any other solution ?

I'm glad @amitchandak's solution worked for you.

amitchandak
Super User
Super User

@bhuprakashs , Create a visual calculation like this and hide the original measure, assuming this a matrix. Else do for all three measures and hide original 

Calculation = if([Brand] ="Brand 1", [Net], [Net]- PREVIOUS([Net]))

 

amitchandak_0-1763651982530.png

Visual Calculations  RUNNINGSUM, RANGE, MOVINGAVERAGE, COLLAPSE, COLLAPSEALL, EXPAND, EXPANDALL, FIRST, LAST, PREVIOUS, and NEXT
https://www.youtube.com/watch?v=bKD9T0EWgQo&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Sorry I got an option to hide the original measure column which is completely hidden from visual. Thanks Amit , visual calculation working properly for me. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.