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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
DikshantKoli
Frequent Visitor

Dynamic Title to display previous month

Hi Folks, 

I am trying to get dynamic title for my card visual. It should display previous month. I used below DAX. 

abc = FORMAT(MONTH(TODAY())-1,"MMM"). 
Current Month is Aug, so result should be Jul but it give me Jan. 
image.png

 

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @DikshantKoli ,

The reason your DAX formula is returning January is that formatting using "MMM" requires a complete date, not just a month number. There are several ways to achieve your desired output, and one approach is as follows:

Previous Month = format(edate(today(),-1),"MMM")

 

DataNinja777_1-1725094441217.png

 

Best regards,

View solution in original post

2 REPLIES 2
v-linhuizh-msft
Community Support
Community Support

Thanks to DataNinja777  for providing a correct answer.

 

Hi @DikshantKoli ,

 

Here I will provide another method for reference:

As DataNinja777 said, formatting using "MMM" requires a complete date.

So the SWITCH function can be used to manually map the month names:

Previous Month =
SWITCH (
    MONTH ( TODAY () ) - 1,
    1, "Jan",
    2, "Feb",
    3, "Mar",
    4, "Apr",
    5, "May",
    6, "Jun",
    7, "Jul",
    8, "Aug",
    9, "Sep",
    10, "Oct",
    11, "Nov",
    12, "Dec"
)

 

vlinhuizhmsft_0-1725258235321.png

 

Best Regards,
Zhu
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

DataNinja777
Super User
Super User

Hi @DikshantKoli ,

The reason your DAX formula is returning January is that formatting using "MMM" requires a complete date, not just a month number. There are several ways to achieve your desired output, and one approach is as follows:

Previous Month = format(edate(today(),-1),"MMM")

 

DataNinja777_1-1725094441217.png

 

Best regards,

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.