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
samurai_jack
Helper I
Helper I

Date to YYYYMM format with DirectQuery

Hi, I have a Date column (dd-mm-yyyy) that I would like to transform into yyyymm. My table is connected via DirectQuery. I used the following m-query for the transformation:

 

Number.ToText(Date.Year([Date]))&Number.ToText(Date.Month([Date]))

 

However I am missing the '0' in front of the single months. Any ideas on how this can be resolved?

 

Thank you!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can use Date.ToText to create a custom column like this:

Date.ToText([Date], [Format="yyyyMM"]))

This doesn't work with DirectQuery though.

 

For DirectQuery, try this:

100 * Date.Year([Date]) + Date.Month([Date])

You can either keep this as an integer or convert it to text.

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

You can use Date.ToText to create a custom column like this:

Date.ToText([Date], [Format="yyyyMM"]))

This doesn't work with DirectQuery though.

 

For DirectQuery, try this:

100 * Date.Year([Date]) + Date.Month([Date])

You can either keep this as an integer or convert it to text.

Thank you very much, this works!

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.