Search code examples
pandaspowerbipowerquerypowerbi-desktopm

Convert date format from dd/mm/yyyy to yyyy-mm-dd with date type Power Bi/Query


I have an issue in Power BI to convert a date dd/mm/yyyy to yyyy-mm-dd but keep the type as a date, because I convert it into text and I had this format but the type is text may someone have an idea how to solve it. Thanks

    #"Type modifié2" = Table.TransformColumnTypes(AjouterCode,{{"DATECREATION", type date}}),
  
    AjouterDateFormatee = Table.AddColumn(#"Type modifié2" , "DATE_CREATION",
        each Date.ToText([DATECREATION], "yyyy-MM-dd")
    ),
#"Type modifié4" = Table.TransformColumnTypes(
    #"Colonnes supprimées",
    {
        {"DATE_CREATION", type date}})

I've tried this :

#"Changed Type1" = Table.TransformColumnTypes(#"Type modifié4",{{"DATE_CREATION", type date}}, "en-GB")

Solution

  • If your date has been correctly parsed in PQ, you don't need to do anything further there. Leave it as a date type and change how that date is displayed in Power BI.

    Select your date column in the data pane:

    enter image description here

    On the ribbon, select Column Tools and manually type in the format as shown. When shown in a visual, the data type will still be date but the format will be your typed format. enter image description here