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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
stats111
Regular Visitor

DAX Format function on date not updating

I'm using the below formula in an attempt to extract the month and year from the data view:

 

 

Date_Mnth_Yr = FORMAT(MONTH([Date]),"mmm")&"-"&YEAR([Date])

 

However the formula isn't updating for all the rows, instead using the same formatted value across all rows.

1 ACCEPTED SOLUTION
KGrice
Memorable Member
Memorable Member

Can you show your a sample where the results are not what you expect? I suspect it's the formula you're using. The current formula formats the month number as a month, not the date's month.

 

For example, if 1 July 2016 is your Date, the current formula will return Jan-2016. It provides the month number, 7, to be formatted as mmm. Trying to pull the month from 7 is the same as pulling the month from 7 Jan 1900, the number 7 converted to a date.

 

If you change your formula to FORMAT([Date], "mmm") & "-" & YEAR([Date]), you'd end up with Jul-2016 from 1 July 2016. You could also use 

 

Date_Mnth_Yr = FORMAT([Date], "mmm-yyyy")

View solution in original post

2 REPLIES 2
KGrice
Memorable Member
Memorable Member

Can you show your a sample where the results are not what you expect? I suspect it's the formula you're using. The current formula formats the month number as a month, not the date's month.

 

For example, if 1 July 2016 is your Date, the current formula will return Jan-2016. It provides the month number, 7, to be formatted as mmm. Trying to pull the month from 7 is the same as pulling the month from 7 Jan 1900, the number 7 converted to a date.

 

If you change your formula to FORMAT([Date], "mmm") & "-" & YEAR([Date]), you'd end up with Jul-2016 from 1 July 2016. You could also use 

 

Date_Mnth_Yr = FORMAT([Date], "mmm-yyyy")


@KGrice wrote:

For example, if 1 July 2016 is your Date, the current formula will return Jan-2016. It provides the month number, 7, to be formatted as mmm. Trying to pull the month from 7 is the same as pulling the month from 7 Jan 1900, the number 7 converted to a date.

 

Thanks, that is exactly what was happening. The solution you provided however did the trick.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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