Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

New Table to Create Categorize Existing Columns

Hello sirs.. I might not have described title clearly.. what I want to do is converting following data;

 

DateUnit1 Unit2Unit3
01.01.2020100200300
02.01.2020150300250

 

into -->

 

DateUnitValue
01.01.20201100
02.01.20201150
01.01.20202200
02.01.20202300
01.01.20203300
02.01.20203250

 

How can I do it ? 

 

Thanks

2 Replies

  • Hi Anonymous 

    Use this code or this PBIX file

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjAyMDJR0lQwMQaQQmjYFkrA5QgRGyAlOYFFAZkB0bCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Unit1 " = _t, Unit2 = _t, Unit3 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Unit1 ", Int64.Type}, {"Unit2", Int64.Type}, {"Unit3", Int64.Type}}),
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date"}, "Attribute", "Value"),
        #"Extracted Text After Delimiter" = Table.TransformColumns(#"Unpivoted Other Columns", {{"Attribute", each Text.AfterDelimiter(_, "Unit"), type text}}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Extracted Text After Delimiter",{{"Attribute", Int64.Type}}),
        #"Sorted Rows" = Table.Sort(#"Changed Type1",{{"Attribute", Order.Ascending}, {"Date", Order.Ascending}})
    in
        #"Sorted Rows"

     

    Regards

    Phil


    If I answered your question please mark my post as the solution.
    If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.