Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Change Date format from YYYYMM to MONTH/YYYY

Hello all,
The data came 07/20/2020 and I changed it to 202007 and I would like it to be shown as July 2020, any thoughts?


I changed the data using this:
Next Gate Date 1 = FORMAT('Table'[Next Gate Date],"YYYYMM")


 

  • In Power Query (where you posted this) you would use this formula in a new column:

    = Date.MonthName([Date]) & " " & Text.From(Date.Year([Date]))

    If you are using DAX and want a calculated column (not recommended), you could use this:

    DAX Date Text = FORMAT([Date], "MMMM YYYY") 

     In general, try to avoid calculated columns. There are times to use them, but it is rare. Getting data out of the source system, creating columns in Power Query, or DAX Measures are usually preferred to calculated columns. See these references:
    Calculated Columns vs Measures in DAX
    Calculated Columns and Measures in DAX
    Storage differences between calculated columns and calculated tables
    Creating a Dynamic Date Table in Power Query

  • Anonymous's avatar
    Anonymous
    6 years ago

     

    seems even if I have not found where it is documented, that to have in the name of the month you have to use capital M.

     

    MMM (3) for short name MMMM (4) for full name

     

    Table.AddColumn(PreviousStep, "Next Gate Date 1", each Date.ToText([Next Gate Date], "MMM/yyyy"))

  • Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

     

    Table:

     

    If you want to create a calculated column, you may try the following dax.

    Column = FORMAT('Table'[Next Gate Date],"mmmm yyyy")

     

    If you want to create a custom column in 'Query Editor', you may go to 'Query Editor'=>'Add Columns' ribbon=>'Custom Column', input the following codes.

    Custom = Date.ToText([Next Gate Date],"MMMM yyyy")

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

7 Replies

  • edhans's avatar
    edhans
    Icon for Community Champion rankCommunity Champion

    In Power Query (where you posted this) you would use this formula in a new column:

    = Date.MonthName([Date]) & " " & Text.From(Date.Year([Date]))

    If you are using DAX and want a calculated column (not recommended), you could use this:

    DAX Date Text = FORMAT([Date], "MMMM YYYY") 

     In general, try to avoid calculated columns. There are times to use them, but it is rare. Getting data out of the source system, creating columns in Power Query, or DAX Measures are usually preferred to calculated columns. See these references:
    Calculated Columns vs Measures in DAX
    Calculated Columns and Measures in DAX
    Storage differences between calculated columns and calculated tables
    Creating a Dynamic Date Table in Power Query

  • v-alq-msft's avatar
    v-alq-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

     

    Table:

     

    If you want to create a calculated column, you may try the following dax.

    Column = FORMAT('Table'[Next Gate Date],"mmmm yyyy")

     

    If you want to create a custom column in 'Query Editor', you may go to 'Query Editor'=>'Add Columns' ribbon=>'Custom Column', input the following codes.

    Custom = Date.ToText([Next Gate Date],"MMMM yyyy")

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous - List of FORMATS can be found here. Shouldn't be a need for that though, there is a default pre-defined format for that:

     

     

  • ziying35's avatar
    ziying35
    Icon for Impactful Individual rankImpactful Individual

    Anonymous 

    Power Query:

    Date.ToText([NextGateDate], "yyyyMM")

  • ziying35's avatar
    ziying35
    Icon for Impactful Individual rankImpactful Individual

    Table.AddColumn(PreviousStep, "Next Gate Date 1", each Date.ToText([Next Gate Date], "yyyyMM"))

    • Anonymous's avatar
      Anonymous
      Not applicable

       

      seems even if I have not found where it is documented, that to have in the name of the month you have to use capital M.

       

      MMM (3) for short name MMMM (4) for full name

       

      Table.AddColumn(PreviousStep, "Next Gate Date 1", each Date.ToText([Next Gate Date], "MMM/yyyy"))