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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hello PBI Community,
I have what I thought might be a common problem.
I need to subtract the cost column by the prior date filtered by the Material number. Here's the table:
Date | Material | Cost |
3/1/2022 | 11223344 | 10,000 |
3/1/2022 | 12345678 | 30,000 |
3/1/2022 | 23456789 | 25,000 |
3/1/2022 | 34567891 | 50,000 |
3/1/2022 | 45678912 | 35,000 |
4/1/2022 | 11223344 | 20,000 |
4/1/2022 | 12345678 | 35,000 |
4/1/2022 | 23456789 | 20,000 |
4/1/2022 | 34567891 | 60,000 |
4/1/2022 | 45678912 | 25,000 |
For example, the difference in cost for Material 11223344 would be +10,000 (20,000 - 10,000).
I am able to create separate Measures for current cost (using MAX function) and previous cost (using PREVIOUSMONTH) then subtracting the measures but was hoping to create a measure where I can subtract any month w/o having to create separate measures.
Any help would be much appreciated!
Thank you,
John
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
Cost Diff measure: =
VAR _currentcost =
SUM ( Data[Cost] )
VAR _previousmonthcost =
CALCULATE ( SUM ( Data[Cost] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )
RETURN
IF (
_currentcost = BLANK ()
|| _previousmonthcost = BLANK (),
" ",
_currentcost - _previousmonthcost
)
Hi,
Please check the below picture and the attached pbix file.
Cost Diff measure: =
VAR _currentcost =
SUM ( Data[Cost] )
VAR _previousmonthcost =
CALCULATE ( SUM ( Data[Cost] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )
RETURN
IF (
_currentcost = BLANK ()
|| _previousmonthcost = BLANK (),
" ",
_currentcost - _previousmonthcost
)
Thanks so much. Very appreciated!
John
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.