Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ksha_001
Regular Visitor

Delta between current month and last month (Monthly Data)

I have a monthly data table with details of multiple clients and their entity IDs. I am trying to calculate the difference between the current month's entity count and the previous month's entity count. I attempted to use some formulas but did not get the desired output. I created a calendar for the dates and then calculated the current and previous month's data. Can someone please assist me with this?

 

Current Month = CALCULATE(COUNT('Query1'[AH_Internal_Claim_ID]), FILTER(ALL('DT'),'DT'[Month Rank]=max('DT'[Month Rank])))
Last Month = CALCULATE(COUNT('Query1'[AH_Internal_Claim_ID]), FILTER(ALL('DT'),'DT'[Month Rank]=max('DT'[Month Rank])-1))

Please see the below example for reference:

 

Input data

transactionMonthscompany
920230331XYZ
1020230331XYZ
1120230331XYZ
1220230331XYZ
1320230331XYZ
1420230331XYZ
120230331ABC
220230331ABC
320230331ABC
420230331ABC
520230331ABC
11320230331TMT
11420230331TMT
11520230331TMT
11620230331TMT
1520230430XYZ
1620230430XYZ
1720230430XYZ
1820230430XYZ
1920230430XYZ
2020230430XYZ
620230430ABC
720230430ABC
820230430ABC
920230430ABC
1020230430ABC
11720230430TMT
11820230430TMT
11920230430TMT
12020230430TMT
2120230531XYZ
2220230531XYZ
2320230531XYZ
2420230531XYZ
2520230531XYZ
2620230531XYZ
1120230531ABC
1220230531ABC
1320230531ABC
1420230531ABC
1520230531ABC
1620230531ABC
1720230531ABC
1820230531ABC
1920230531ABC
12120230531TMT
12220230531TMT
12320230531TMT
12420230531TMT
12520230531TMT
12620230531TMT
12720230531TMT
12820230531TMT
12920230531TMT
13020230531TMT

 

Output: 

Company202303312023043020230531Current-Previous Month
ABC5594
TMT44106
XYZ6660
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@ksha_001 Should be something like this:

Measure = 
    VAR __Current = MAX('Table'[Months])
    VAR __PrevMonth = MAXX(FILTER('Table', [Months] <> __Current), [Months])
    VAR __CurrentTable = FILTER('Table', [Months] = __Current)
    VAR __PrevMonthTable = FILTER('Table', [Months] = __PrevMonth)
    VAR __Result = COUNTROWS(__CurrentTable) - COUNTROWS(__PrevMonthTable)
RETURN
    __Result

But, to get it in the form that you are showing, you will need something like this: The New Hotness (Custom Matrix Hierarchy) - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@ksha_001 Should be something like this:

Measure = 
    VAR __Current = MAX('Table'[Months])
    VAR __PrevMonth = MAXX(FILTER('Table', [Months] <> __Current), [Months])
    VAR __CurrentTable = FILTER('Table', [Months] = __Current)
    VAR __PrevMonthTable = FILTER('Table', [Months] = __PrevMonth)
    VAR __Result = COUNTROWS(__CurrentTable) - COUNTROWS(__PrevMonthTable)
RETURN
    __Result

But, to get it in the form that you are showing, you will need something like this: The New Hotness (Custom Matrix Hierarchy) - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you @Greg_Deckler . That worked. Regarding renaming the total field, I have a question. When I try to rename the field by right-clicking, the change doesn't reflect on the canvas. Is this a Power BI limitation?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.