This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi,
I have searched the forums but didn't find anything that was what I'm trying to do and my attempts to change other formulae and use the quick measures haven't worked. I'm trying to create the two columns shown in the table below "Difference" and % Difference, I've populated these with my expected values already but can't do this using Power BI.
The step column is used as a counter and first "Step" is always 1 and the last "Step" is always 6.
For the "Difference" column, every step except 6 and 1 needs to subtract its value from the previous step "value" (1 just equals 0 and 6 needs to subtract from 1's value to get the overall change).
For the "% Difference" column, every step except 6 and 1 should be Difference divided by the previous step "Value" (1 just equals 0 and 6 needs to divide by 1's value to get the overall % diff).
Please can anyone help? I'm running out of ideas!
Thanks, Mike
| Category | Step | Value | Difference | % difference |
| A | 1 | 100 | 0 | 0% |
| A | 2 | 105 | 5 | 5% |
| A | 3 | 106 | 1 | 1% |
| A | 4 | 80 | -26 | -25% |
| A | 6 | 90 | -10 | -10% |
| B | 1 | 50 | 0 | 0% |
| B | 2 | 55 | 5 | 10% |
| B | 3 | 40 | -15 | -27% |
| B | 4 | 60 | 20 | 50% |
| B | 5 | 80 | 20 | 33% |
| B | 6 | 90 | 40 | 80% |
Solved! Go to Solution.
Hi @MT54 ,
I suggest you to try code as below to create calculated columns.
Difference =
VAR _1 = 0
VAR _2to5 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Category] ),
'Table'[Step]
= EARLIER ( 'Table'[Step] ) - 1
)
)
VAR _6 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Category] ), 'Table'[Step] = 1 )
)
RETURN
IF (
'Table'[Step] = 1,
_1,
IF ( 'Table'[Step] = 6, 'Table'[Value] - _6, 'Table'[Value] - _2to5 )
)% difference =
VAR _1 = 0
VAR _2to5 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Category] ),
'Table'[Step]
= EARLIER ( 'Table'[Step] ) - 1
)
)
VAR _6 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Category] ), 'Table'[Step] = 1 )
)
RETURN
IF (
'Table'[Step] = 1,
_1,
DIVIDE ( 'Table'[Difference], IF ( 'Table'[Step] = 6, _6, _2to5 ) )
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @MT54 ,
I suggest you to try code as below to create calculated columns.
Difference =
VAR _1 = 0
VAR _2to5 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Category] ),
'Table'[Step]
= EARLIER ( 'Table'[Step] ) - 1
)
)
VAR _6 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Category] ), 'Table'[Step] = 1 )
)
RETURN
IF (
'Table'[Step] = 1,
_1,
IF ( 'Table'[Step] = 6, 'Table'[Value] - _6, 'Table'[Value] - _2to5 )
)% difference =
VAR _1 = 0
VAR _2to5 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Category] ),
'Table'[Step]
= EARLIER ( 'Table'[Step] ) - 1
)
)
VAR _6 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Category] ), 'Table'[Step] = 1 )
)
RETURN
IF (
'Table'[Step] = 1,
_1,
DIVIDE ( 'Table'[Difference], IF ( 'Table'[Step] = 6, _6, _2to5 ) )
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 30 | |
| 28 | |
| 23 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 48 | |
| 46 | |
| 41 | |
| 21 | |
| 18 |