Forum Discussion

o59393's avatar
o59393
Post Prodigy
6 years ago
Solved

Date format

Hi all

 

How can I convert a date in format "Apr 01 2019" to "April 2019" for example and using power query?

 

https://1drv.ms/u/s!ApgeWwGTKtFdhjOrLr9_z4xQWZca?e=KpC6mb 

 

Thanks.

 

 

 

  • o59393 ,

    You have to go to Transform Data/Edit Query and use the Custom Column option.

    In Dax , you can try like

     format(DATEVALUE("Apr 01 2019"),"MMMM-YYYY")

     

    If it a static value you can use in measure too. Else in measure use some aggregation.

     

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Perhaps:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoUjAwVDAyMLRUitWJVvJKzIPwjQzAfLfUJAUDYwTfqzRHwdAUyo8FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Added Custom Column" = Table.AddColumn(Source, "Custom", each Text.Combine({Date.ToText(Date.From([Column1]), "MMMM"), " ", Date.ToText(Date.From([Column1]), "yyyy")}), type text)
    in
        #"Added Custom Column"

     

    • o59393's avatar
      o59393
      Post Prodigy

      Hi 

       

      Where do I have to paste that?

       

      As an added custom column?


      Thanks!

       

      • amitchandak's avatar
        amitchandak
        Super User

        o59393 ,

        You have to go to Transform Data/Edit Query and use the Custom Column option.

        In Dax , you can try like

         format(DATEVALUE("Apr 01 2019"),"MMMM-YYYY")

         

        If it a static value you can use in measure too. Else in measure use some aggregation.

         

  • FrankAT's avatar
    FrankAT
    Community Champion

    Hi o59393,

    if you change the date in the desired format with Power Query the result will end up in a string. Sort order is alphabetical.

    If you want to keep the date intact format it in model view:

    1. Seelect model view.
    2. Select date field in field list.
    3. See figure. Sort order by calendar.

     

    Regards FrankAT