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

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.

Reply

Calculate difference between consecutive rows / columns

Please help...

I am currently running through a similar issue, in that I would like to display the differences between values.

 

     Column 1 | Column 2 | Column 3 | Column 4 | Column 5

           200           100            350            900              800

 

Diff:           -100          +250          +550            -100

 

Please help. I would real really appreciate the assistance. 

 

Thanks. 

1 ACCEPTED SOLUTION

Hi,

 

You could try and create this calculated column

Calculated column = 
VAR RowAbove=
CALCULATE (
SUM (Table[Value]),
FILTER (Table, Table[Index] = EARLIER (Table[Index]) - 1))
RETURN
Table[Value] - RowAbove

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@PowerEnthusiast  - It would be straightforward to create a new Calculated Column for each of those values - is that what you're looking for? If so, here is an example:

Diff One vs Two = [Column 1] - [Column 2]

If that is not what you're looking for, could you please elaborate on the desired behavior?

Cheers,

Nathan

 

 

Thank you for the reply.

Apologies, I am new to all this. 

 

I have various account names that needed to be sorted, so I included an index field. Then I wanted to calculate the difference between the Account Names, but ensuring that the difference is calculated in the order as shown below. 

Capture.JPG

Hi,

 

You could try and create this calculated column

Calculated column = 
VAR RowAbove=
CALCULATE (
SUM (Table[Value]),
FILTER (Table, Table[Index] = EARLIER (Table[Index]) - 1))
RETURN
Table[Value] - RowAbove
Anonymous
Not applicable

Hey @Gordonlilj 
What If I want to calculate sum of all those differences and put it in a card?!!

@Gordonlilj Oh wow thank you so much. This is perfect. 

 

Appreciate the help. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.