none
How to change Date formats in Power Query/ Power BI? RRS feed

  • Question

  • Hi,

    I have three date columns in my Power BI data model. All are in dd-mm-yyyy or dd-mmm-yyyy formats, but I want to change them in to any format I want (i.e. from dd-mm-yyyy to mm-dd-yyyy or mmm-dd-yyyy etc) quickly up on my need. Is there a way for the same?

    I think Power Query lacks a direct solution, Am I wrong? Please let me know If you have solution using DAX or M language?

    Thank you

    Arjun


    ArjunMShetty


    Monday, May 6, 2019 1:36 PM

All replies

  • Hi Arjun,

    Suppose, you have such table:

    Then you may use following code to transform dates:

    = Table.TransformColumns(YourTable, {"Date", each Date.ToText(Date.From(_),"MM-dd-yyyy")})
    Monday, May 6, 2019 2:12 PM
  • Hi Aleksei,

    Thanks for the reply.

    It's confusing when I try this, may be because of small typos/Caps.

    Is there no direct solution in the form of a "ready-click button" any where in Power BI?

    What should be the code looks when my table name is Sales and column is OrderDate?

    How to use this code? Is it through Custom column option?



    ArjunMShetty

    Tuesday, May 7, 2019 6:35 AM
  • Hi Arjun,

    Well, suppose, you have such query in Query Editor:

    Then you should click fx button and insert this code into formula bar:

    = Table.TransformColumns(YourLastStep, {"OrderDate", each Date.ToText(Date.From(_),"MM-dd-yyyy")})
    Obviously, instead YourLastStep you should specify the name of your last step.
    Tuesday, May 7, 2019 8:28 AM