Forum Discussion

AlwaysLearner's avatar
AlwaysLearner
New Member
1 year ago
Solved

Beginner Needs Help: Can't Figure Out How to Transform "Dirty" Date Format Using UI Only

Hi everyone,

I'm a complete beginner with Power Query and I'm really struggling with what's probably a basic transformation. I have an Excel file with two tabs - the first contains my "dirty" data with a messy date format, and the second shows what I want the "clean" output to look like.

I've been trying for hours using the UI (transpose, transform, remove headers, etc.) but I just can't figure out how to get from the dirty format to the clean format. I feel like I'm missing something fundamental about how these transformations work.

I know this is probably Power Query 101 stuff, but I'd really appreciate any guidance on the steps I should be taking. I learn better by seeing the actual UI steps rather than code, if possible.

Would anyone be willing to take a quick look and point me in the right direction? I'm happy to share the file if that would help.

Thanks so much for your patience with a newbie!

Here the link to the file:

https://foresightbi.com.ng/wp-content/uploads/2020/05/3.-Badly-Structured-Sales-Data-3.xlsx 

  • Hi - the first thing I did was make a slight tweek to the dirty data so that the headers become usable in Power Query for what you want. I filled in the blank Ship Modes then added a row that concatenates the ship mode and segment.

    Once in Power Query, I did this:

    No transformations

     

    1. Promoted Headers

    2. Change Type (Power BI did this by default - you can adjust if you want)

    3. I selected the first two columns, then performed Unpivot Other Columns

    4. Remove top rows - removed top 24 rows from above

    5. Separated Attribute by delimiter of -

    6. Now you can rename the columns to whatever you want.

     

    let
    Source = Excel.Workbook(File.Contents("C:\Users\audrey.gerred\Downloads\3.-Badly-Structured-Sales-Data-3.xlsx"), null, true),
    #"Dirty 3_Sheet" = Source{[Item="Dirty 3",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(#"Dirty 3_Sheet", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", type text}, {"Column2", type any}, {"First Class-Consumer", type any}, {"First Class-Corporate", type any}, {"First Class-Home Office", type any}, {"Same Day-Consumer", type any}, {"Same Day-Corporate", type any}, {"Same Day-Home Office", type any}, {"Second Class-Consumer", type any}, {"Second Class-Corporate", type any}, {"Second Class-Home Office", type any}, {"Standard Class-Consumer", type any}, {"Standard Class-Corporate", type any}, {"Standard Class-Home Office", type any}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Column1", "Column2"}, "Attribute", "Value"),
    #"Removed Top Rows" = Table.Skip(#"Unpivoted Other Columns",24),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Top Rows", "Attribute", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}})
    in
    #"Changed Type1"

     

     

     

     

8 Replies

    • AlwaysLearner's avatar
      AlwaysLearner
      New Member

      Hi Sundar, 

      thank you very much for the file and the time you have invested in. But unfortunately this is not helpfull. As I already new how the Clean file has to look like. My problem is that I do not understand how the transformation is done. That means I need a walkthrough how to handle the file in Power Query to reach the "clean" State.

  • Hi Omid, 

    thank you very much for the file and the time you have invested in. But unfortunately this is not helpfull. As I already new how the Clean file has to look like. My problem is that I do not understand how the transformation is done. That means I need a walkthrough how to handle the file in Power Query to reach the "clean" State.

    I'm greatful for the link to you youtube channel. I will have a look into it. 

    Thank you very much

  • Hi - the first thing I did was make a slight tweek to the dirty data so that the headers become usable in Power Query for what you want. I filled in the blank Ship Modes then added a row that concatenates the ship mode and segment.

    Once in Power Query, I did this:

    No transformations

     

    1. Promoted Headers

    2. Change Type (Power BI did this by default - you can adjust if you want)

    3. I selected the first two columns, then performed Unpivot Other Columns

    4. Remove top rows - removed top 24 rows from above

    5. Separated Attribute by delimiter of -

    6. Now you can rename the columns to whatever you want.

     

    let
    Source = Excel.Workbook(File.Contents("C:\Users\audrey.gerred\Downloads\3.-Badly-Structured-Sales-Data-3.xlsx"), null, true),
    #"Dirty 3_Sheet" = Source{[Item="Dirty 3",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(#"Dirty 3_Sheet", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", type text}, {"Column2", type any}, {"First Class-Consumer", type any}, {"First Class-Corporate", type any}, {"First Class-Home Office", type any}, {"Same Day-Consumer", type any}, {"Same Day-Corporate", type any}, {"Same Day-Home Office", type any}, {"Second Class-Consumer", type any}, {"Second Class-Corporate", type any}, {"Second Class-Home Office", type any}, {"Standard Class-Consumer", type any}, {"Standard Class-Corporate", type any}, {"Standard Class-Home Office", type any}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Column1", "Column2"}, "Attribute", "Value"),
    #"Removed Top Rows" = Table.Skip(#"Unpivoted Other Columns",24),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Top Rows", "Attribute", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}})
    in
    #"Changed Type1"

     

     

     

     

  • v-sgandrathi's avatar
    v-sgandrathi
    Icon for Community Support rankCommunity Support

    Hi AlwaysLearner,

    Thank you audreygerredSundarRaj, and Omid_Motamedise for your response.

    We wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.

    If you need any further assistance, feel free to reach out.

    Thank you for being a valued member of the Microsoft Fabric Community Forum!

    • v-sgandrathi's avatar
      v-sgandrathi
      Icon for Community Support rankCommunity Support

      Hi AlwaysLearner,

       

      We wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.

      If you need any further assistance, feel free to reach out.

       

      Thank you for being a valued member of the Microsoft Fabric Community Forum!

      • v-sgandrathi's avatar
        v-sgandrathi
        Icon for Community Support rankCommunity Support

        Hi AlwaysLearner,

         

        I wanted to follow up on our previous suggestions regarding the issue. We would love to hear back from you to ensure we can assist you further.

        Please let us know if there’s anything else we can do to help.

        Thank you.