Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hey guys, I would like to sort on part of my headers, I have sth like that:
primary event type | secondary eventtype | 2022-07 | 2022-06 | 2022-05 | 2022-04 | 2022-03 | 2022-02 | 2022-01 | 2021-12 |
event | event | 583 | 583 | 583 | 583 | 583 | 583 | 583 | 583 |
event | event | 583 | 583 | 583 | 583 | 583 | 583 | 583 | 583 |
event | event | 7785 | 583 | 583 | 583 | 583 | 583 | 583 | 583 |
event | event | 583 | 5534 | 583 | 583 | 583 | 8786 | 4434 | 583 |
event | event | 583 | 583 | 4465 | 884 | 3578 | 583 | 583 | 583 |
event | event | 583 | 583 | 583 | 583 | 583 | 583 | 583 | 583 |
I'm new to power BI, I have created a slicer on my primary and secondary event types, and I would like to sort my data based on the rest of the headers. However, I'm having trouble doing so. It would be helpful if someone can give some hints
Solved! Go to Solution.
The very first thing you want to do is bring the data into a usable format. You do that by unpivoting it.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSi1LzStR0oHTphbGJJCxOrQwwdzcwpQ6jjA1NsGqzcLcwgxImZjA5Qn5xMTEDOQmCwuQBmNTcwvahEYsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"primary event type" = _t, #"secondary eventtype" = _t, #"2022-07" = _t, #"2022-06" = _t, #"2022-05" = _t, #"2022-04" = _t, #"2022-03" = _t, #"2022-02" = _t, #"2022-01" = _t, #"2021-12" = _t]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"primary event type", "secondary eventtype"}, "Attribute", "Value"),
#"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", Int64.Type}})
in
#"Changed Type"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
The very first thing you want to do is bring the data into a usable format. You do that by unpivoting it.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSi1LzStR0oHTphbGJJCxOrQwwdzcwpQ6jjA1NsGqzcLcwgxImZjA5Qn5xMTEDOQmCwuQBmNTcwvahEYsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"primary event type" = _t, #"secondary eventtype" = _t, #"2022-07" = _t, #"2022-06" = _t, #"2022-05" = _t, #"2022-04" = _t, #"2022-03" = _t, #"2022-02" = _t, #"2022-01" = _t, #"2021-12" = _t]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"primary event type", "secondary eventtype"}, "Attribute", "Value"),
#"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", Int64.Type}})
in
#"Changed Type"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".