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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Iaine
New Member

Changing YYYYMM to a valid date format

I wonder if anyone has figured out how to take 'YYYYMM' as a number field to turn it into a valid time period in power query. I have manged it in Power Bi Desktop, but as i need to do some things on it in power query it does not show.

 

Any help would be awesome 

 

Iain 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Iaine ,

 

You could create a new custom column, something like this:

#date(
    Number.From(Text.Start(Text.From([dateKeyField]), 4)),
    Number.From(Text.End(Text.From([dateKeyField]), 2)),
    01
)

 

This gives me the following output:

BA_Pete_0-1662393261165.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

You can also use math functions to isolate the year and month components.

 

#date(
    Number.IntegerDivide([Column1], 100),
    Number.Mod([Column1],100),
    1
)

 

 

Another option is to use Date.FromText with an explicit Format specification:

 

Date.FromText(Text.From([Column1]), [Format="yyyyMM"]))

 

BA_Pete
Super User
Super User

Hi @Iaine ,

 

You could create a new custom column, something like this:

#date(
    Number.From(Text.Start(Text.From([dateKeyField]), 4)),
    Number.From(Text.End(Text.From([dateKeyField]), 2)),
    01
)

 

This gives me the following output:

BA_Pete_0-1662393261165.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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