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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Ongoing Comparison of Last Completed Month to Prior Month

Based on my table below I want to isolate that 13 figure as a measure and be able to plot it on a graph so that I can compare what makes up that 13 difference (which clients gained the most revenue last month compared to the month prior)

 

I tried to do a conditional column that would look only at April but when I did that and applied the filter it caused the last month figure to be blank so the difference was 73.  When may data is loaded I want to compare may with april and so on.

 
flag = IF('Date'[Year]=[Today-year] && 'Date'[Monthnumber]=[lastmonth],1,0) -- didn't work 

 

Last Month Revenue = CALCULATE([Revenue], DATEADD('Date'[Date].[Date], -1, MONTH))

Difference = Revenue - Last Month Revenue 

 

DateThis Month RevenueLast Month RevenueDifference
February 20503812
March 20605010
April 20736013
May 20No data yet, so blank73-73
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

It's difficult to say definitively given the information provided. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

 

That said, from what you describe, you generally do things like that the following way:

Diff =
  VAR __ThisMonthRevenue = SUM([Revenue]) //should have current month in context
  VAR __CurrentDate = MAX([Date]) //again, current month in context have a date in current month
  VAR __LastMonthDate = EOMONTH(__CurrentDate,-1) // end date of last month
  VAR __LastMonthStart = DATE(YEAR(__LastMonthDate),MONTH(__LastMonthDate),1)) //1st of last month
  VAR __ThisMonthStart = DATE(YEAR(__CurrentDate),MONTH(__CurrentDate),1)) //1st of current month
RETURN
  __ThisMonthRevenue - SUMX(FILTER(ALL('Table'),[Date]>=__LastMonthStart && [Date]<__ThisMonthStart),[Revenue]) //ALL overrides filter context

 

This is a general solution that would need to be adapted to your data. 

 

 



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

It's difficult to say definitively given the information provided. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

 

That said, from what you describe, you generally do things like that the following way:

Diff =
  VAR __ThisMonthRevenue = SUM([Revenue]) //should have current month in context
  VAR __CurrentDate = MAX([Date]) //again, current month in context have a date in current month
  VAR __LastMonthDate = EOMONTH(__CurrentDate,-1) // end date of last month
  VAR __LastMonthStart = DATE(YEAR(__LastMonthDate),MONTH(__LastMonthDate),1)) //1st of last month
  VAR __ThisMonthStart = DATE(YEAR(__CurrentDate),MONTH(__CurrentDate),1)) //1st of current month
RETURN
  __ThisMonthRevenue - SUMX(FILTER(ALL('Table'),[Date]>=__LastMonthStart && [Date]<__ThisMonthStart),[Revenue]) //ALL overrides filter context

 

This is a general solution that would need to be adapted to your data. 

 

 



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.