Forum Discussion

brankocareer's avatar
brankocareer
Helper I
2 years ago
Solved

Column change form of expression

Hi all,

 

I want to create a report to show the change of any column in a database. Current the table is like this: 

What I need is showing like this:

What I can do?

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi lbendlin ,

    Thanks for your quick response.

    Hi brankocareer ,

    Please refer to my pbix file to see if it helps you.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjUwMDQwNzFU0lEqS0xOzCsBMpJKizPzUouLFYpTi8oyk1OLgWK+mXmZxSVFlQrFpQUF+UUlCLlYHRRT0jJzclJTSDclFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"postition id" = _t, #"postion status" = _t, branch = _t, unit = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"postition id", Int64.Type}, {"postion status", type text}, {"branch", type text}, {"unit", type text}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"postition id", "branch", "unit"}, "Attribute", "Value"),
        #"Added Index" = Table.AddIndexColumn(#"Unpivoted Columns", "Index", 1, 1, Int64.Type),
        #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Added Index", {{"Index", type text}}, "en-US"),{"Attribute", "Index"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Postatus"),
        #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Postatus]), "Postatus", "Value")
    in
        #"Pivoted Column"

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

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

     

     

     

     

2 Replies

  • First thing is to bring your own index column. Power Query has no natural sort order.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi lbendlin ,

    Thanks for your quick response.

    Hi brankocareer ,

    Please refer to my pbix file to see if it helps you.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjUwMDQwNzFU0lEqS0xOzCsBMpJKizPzUouLFYpTi8oyk1OLgWK+mXmZxSVFlQrFpQUF+UUlCLlYHRRT0jJzclJTSDclFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"postition id" = _t, #"postion status" = _t, branch = _t, unit = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"postition id", Int64.Type}, {"postion status", type text}, {"branch", type text}, {"unit", type text}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"postition id", "branch", "unit"}, "Attribute", "Value"),
        #"Added Index" = Table.AddIndexColumn(#"Unpivoted Columns", "Index", 1, 1, Int64.Type),
        #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Added Index", {{"Index", type text}}, "en-US"),{"Attribute", "Index"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Postatus"),
        #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Postatus]), "Postatus", "Value")
    in
        #"Pivoted Column"

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

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