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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Convert Text date to date format

I have a text date field in the format of YYYYMMDD. I need to be able to reference just the YYYYMM in a slicer. How can I get this into a slicer?

 

Thanks

5 REPLIES 5
Kaviraj11
Super User
Super User

Hi,

 

There's a couple of ways you can create a format and use in slicer

  1. Calculated Column in Date Table:

    • If you have a date table, create a calculated column with the following formula:
      Date_New = FORMAT('my_data'[Date], "YYYYMM")
  2. M Query in Query Editor:

    • In the Query Editor, write a single M statement to convert YYYYMMDD to a proper date format:
      Date.From(Text.From([Date], "en-US"))
  3. Concatenation for Month Slicer:

    • If you want to use the YYYYMM as a slicer, you can create a calculated column for the month:
      Yearmonth = CONCATENATE(YEAR([Date]), MONTH([Date]))

      Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Ashish_Mathur
Super User
Super User

Hi,

This custom column in Power Query will work

Date.From(Text.From([DateKey], "en-US")  

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Ashish, Could you provide an example. I'm not sure I understand the syntax.

 

Thanks

Hi,

That code simply has to be pasted in the Custom Column window of Power Query.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Irwan
Super User
Super User

hello @Anonymous 

 

you need to extract year, month, and day value from that string to create date format YYYY-MM-DD.

this is one way of many ways.

Both DAX and Power Query work same (extract string number).

if you want to use DAX.

Date format DAX =
var _year = LEFT('Table'[Column1],4) //extract year number
var _day = RIGHT('Table'[Column1],2) //extract day number
var _month = RIGHT('Table'[Column1],4)-RIGHT('Table'[Column1],2)
var _monthnum = SUBSTITUTE(_month,RIGHT(_month,2),"") //extract month number
Return
DATEVALUE(CONCATENATE(CONCATENATE(_year&"-",_monthnum&"-"),_day))
 
if you want to use Power Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjEwMzRUitWBcAwNDU2VYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}),
#"Inserted First Characters" = Table.AddColumn(#"Changed Type", "First Characters", each Text.Start(Text.From([Column1], "en-ID"), 4), type text),
#"Inserted Text Range" = Table.AddColumn(#"Inserted First Characters", "Text Range", each Text.Middle(Text.From([Column1], "en-ID"), 4, 6), type text),
#"Extracted First Characters" = Table.TransformColumns(#"Inserted Text Range", {{"Text Range", each Text.Start(_, 2), type text}}),
#"Inserted Last Characters" = Table.AddColumn(#"Extracted First Characters", "Last Characters", each Text.End(Text.From([Column1], "en-ID"), 2), type text),
#"Merged Columns" = Table.CombineColumns(#"Inserted Last Characters",{"First Characters", "Text Range", "Last Characters"},Combiner.CombineTextByDelimiter("-", QuoteStyle.None),"Date"),
#"Changed Type1" = Table.TransformColumnTypes(#"Merged Columns",{{"Date", type date}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Date", "Date Power Query"}})
in
#"Renamed Columns"
 
Irwan_0-1721428371976.png

 

dont forget to change data type into date after using DAX or Power Query since both result still in text.

Irwan_1-1721428491110.png

 

Hope this will help you.

Thank you.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

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.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.