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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

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

3 REPLIES 3
manishcal116
Frequent Visitor

I Have date in SQL server YYYYMM varchar i need to  change in date. i am using direct Query Mode

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.

Anonymous
Not applicable

Thank you very much, this works!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.