BM78
BM78

Reputation: 9

Calculate a measure difference between two rows in Power BI

Fisc 20-21 21-22 22-23 23-24 24-25
A 10 15 30 25 5
B 100 85 35 15 30

this is the initial table imported from Excel in Power Bi :

Table name : prog

I want to create a measure to calculate the difference between rows to display a table like the Following:

20-21 21-22 22-23 23-24 24-25
Diff B-A 90 60 5 -10 25

this is what i used but doesn't work :

_DiffB-A = 
CALCULATE(
    SUM('prog'[B]) - SUM('prog'[A]),
    ALL('prog'[Fisc])
)

I tried to use the index but all solution are adding a new column and not a row.

Thanks.

Upvotes: 0

Views: 258

Answers (1)

Ryan
Ryan

Reputation: 2482

you can try this

  1. In power query, select the first column and unpivot other columns

enter image description here enter image description here

then create a measure

Measure = CALCULATE(sum(prog[Value]),prog[Fisc]="B")- CALCULATE(sum(prog[Value]),prog[Fisc]="A")

enter image description here

Upvotes: 1

Related Questions