Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi
I've created a measure to calculate the difference between rows:
Now, the dataset contains multiple buildings and 2 types
Can someone help me out adjusting the measure so I can get the expected result?
Thnx!
Solved! Go to Solution.
Hi @jochendecraene ,
You can create a calculated column as below to get it:
Consumption =
VAR _predate =
CALCULATE (
MAX ( 'Tabel1'[date] ),
FILTER (
'Tabel1',
'Tabel1'[Building] = EARLIER ( Tabel1[Building] )
&& 'Tabel1'[type] = EARLIER ( Tabel1[type] )
&& 'Tabel1'[ID] = EARLIER ( Tabel1[ID] )
&& 'Tabel1'[date] < EARLIER ( Tabel1[date] )
)
)
VAR _pdmeter =
CALCULATE (
SUM ( 'Tabel1'[Meter reading] ),
FILTER (
'Tabel1',
'Tabel1'[Building] = EARLIER ( Tabel1[Building] )
&& 'Tabel1'[type] = EARLIER ( Tabel1[type] )
&& 'Tabel1'[date] = _predate
)
)
RETURN
IF ( ISBLANK ( _pdmeter ), BLANK (), 'Tabel1'[Meter reading] - _pdmeter )
Best Regards
Hi @jochendecraene ,
You can create a calculated column as below to get it:
Consumption =
VAR _predate =
CALCULATE (
MAX ( 'Tabel1'[date] ),
FILTER (
'Tabel1',
'Tabel1'[Building] = EARLIER ( Tabel1[Building] )
&& 'Tabel1'[type] = EARLIER ( Tabel1[type] )
&& 'Tabel1'[ID] = EARLIER ( Tabel1[ID] )
&& 'Tabel1'[date] < EARLIER ( Tabel1[date] )
)
)
VAR _pdmeter =
CALCULATE (
SUM ( 'Tabel1'[Meter reading] ),
FILTER (
'Tabel1',
'Tabel1'[Building] = EARLIER ( Tabel1[Building] )
&& 'Tabel1'[type] = EARLIER ( Tabel1[type] )
&& 'Tabel1'[date] = _predate
)
)
RETURN
IF ( ISBLANK ( _pdmeter ), BLANK (), 'Tabel1'[Meter reading] - _pdmeter )
Best Regards
thank you very much @Anonymous
Thank you so much @Anonymous !
Is it possible to give a brief explanation on how this measure works? Any hints on good resources to learn more about this kind of DAX?
Hi @jochendecraene ,
As you can see the formula below, there are two variables:
Consumption =
VAR _predate =
CALCULATE (
MAX ( 'Tabel1'[date] ),
FILTER (
'Tabel1',
'Tabel1'[Building] = EARLIER ( Tabel1[Building] )
&& 'Tabel1'[type] = EARLIER ( Tabel1[type] )
&& 'Tabel1'[ID] = EARLIER ( Tabel1[ID] )
&& 'Tabel1'[date] < EARLIER ( Tabel1[date] )
)
)
VAR _pdmeter =
CALCULATE (
SUM ( 'Tabel1'[Meter reading] ),
FILTER (
'Tabel1',
'Tabel1'[Building] = EARLIER ( Tabel1[Building] )
&& 'Tabel1'[type] = EARLIER ( Tabel1[type] )
&& 'Tabel1'[date] = _predate
)
)
RETURN
IF ( ISBLANK ( _pdmeter ), BLANK (), 'Tabel1'[Meter reading] - _pdmeter )
You can review the following links to learn DAX:
Best Regards
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 54 | |
| 51 | |
| 39 | |
| 15 | |
| 14 |
| User | Count |
|---|---|
| 93 | |
| 79 | |
| 37 | |
| 27 | |
| 25 |