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
Anonymous
Not applicable

Dynamic Title to show Prior Month from Selected Value

I have  visual where I want the table to say 'Current Month vs Last Month' with the month names changing dynamically based on slicer value.

 

What I have currently is this:

Current v Prior Month = SELECTEDVALUE('Date'[Month Name Short])& " " &SELECTEDVALUE('Date'[Year])&" versus Prior Month"
So, if Feb 2023 is selected it says "Feb 2023 versus Prior Month".
What I want it to say is "Feb 2023 versus Mar 2023"
My search has only provided solutions that don't involve a slicer by using TODAY or NOW.
 
Can this be done?
 
Thanks
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Assuming you meant Feb 2023 vs. Jan 2023 and making various other assumptions about your data model then perhaps something like this:

Current v Prior Month = 
  VAR __CurDate = MAX('Date'[Date])
  VAR __CurMonth = SELECTEDVALUE('Date'[Month Name Short])
  VAR __CurYear = SELECTEDVALUE('Date'[Year])
  VAR __PrevDate = EOMONTH(__CurDate, -1)
  VAR __PrevMonth = FORMAT(__PrevDate, "mmm")
  VAR __PrevYear = YEAR(__PrevDate)
  VAR __Result = __CurMonth & " " & __CurYear & " versus " & __PrevMonth & " " & __PrevYear
RETURN
  __Result


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

@Anonymous Assuming you meant Feb 2023 vs. Jan 2023 and making various other assumptions about your data model then perhaps something like this:

Current v Prior Month = 
  VAR __CurDate = MAX('Date'[Date])
  VAR __CurMonth = SELECTEDVALUE('Date'[Month Name Short])
  VAR __CurYear = SELECTEDVALUE('Date'[Year])
  VAR __PrevDate = EOMONTH(__CurDate, -1)
  VAR __PrevMonth = FORMAT(__PrevDate, "mmm")
  VAR __PrevYear = YEAR(__PrevDate)
  VAR __Result = __CurMonth & " " & __CurYear & " versus " & __PrevMonth & " " & __PrevYear
RETURN
  __Result


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...
Anonymous
Not applicable

Exactly what I wanted!

Thanks!

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.