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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
atowriss99
Helper I
Helper I

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

@atowriss99 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

@atowriss99 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...

Exactly what I wanted!

Thanks!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors