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 everyone,
I am new to Power BI and DAX and I'm finding it difficult to find the difference between two rows.
As shown in the sample data, I have many Machine codes, and cumulative values of thier operating hours and cycles are available in the table. The data is in no particular order, and I would like to be able to find the hours and cylces for a particular month by calculating the difference between two consecutive months as a Calculated Column or a Measure.
Any help would be greatly appreciated.
Regards,
Preetish
Solved! Go to Solution.
You may create calculated columns as shown below.
CurrentDate =
DATEVALUE (
RIGHT ( Table1[Date], 4 ) & "-"
& MID ( Table1[Date], 4, 2 )
& "-"
& LEFT ( Table1[Date], 2 )
)
Difference =
VAR Prev =
CALCULATE (
SUM ( Table1[Values] ),
ALLEXCEPT ( Table1, Table1[MC Code], Table1[Type] ),
PREVIOUSMONTH ( Table1[CurrentDate] )
)
RETURN
IF ( ISBLANK ( Prev ), BLANK (), Table1[Values] - Prev )
You may create calculated columns as shown below.
CurrentDate =
DATEVALUE (
RIGHT ( Table1[Date], 4 ) & "-"
& MID ( Table1[Date], 4, 2 )
& "-"
& LEFT ( Table1[Date], 2 )
)
Difference =
VAR Prev =
CALCULATE (
SUM ( Table1[Values] ),
ALLEXCEPT ( Table1, Table1[MC Code], Table1[Type] ),
PREVIOUSMONTH ( Table1[CurrentDate] )
)
RETURN
IF ( ISBLANK ( Prev ), BLANK (), Table1[Values] - Prev )
Thank you @vanessafvg, I tried it but I did not know how to filter the data.
Thank you very much @v-chuncz-msft , your recommendation works perfectly.
Thanks for your help.
@Preetish_1 have you tried previous month? https://msdn.microsoft.com/en-us/library/ee634758.aspx
Proud to be a Super User!
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 |
|---|---|
| 53 | |
| 47 | |
| 30 | |
| 15 | |
| 14 |
| User | Count |
|---|---|
| 88 | |
| 73 | |
| 38 | |
| 26 | |
| 25 |