Forum Discussion
How to show values as column headers
- 3 years ago
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0MACSPvm5SYlFKZVApmNpSWlunlKsTrSSEZBrBJFPrMrMB9LBpbm5qUVgSWMg1xhdM0w+FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [key = _t, value = _t, region = _t, stagionality = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"key", Int64.Type}, {"value", Int64.Type}, {"region", type text}, {"stagionality", type text}}), #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"key", "value"}, "Attribute", "Value.1"), #"Sorted Rows" = Table.Sort(#"Unpivoted Columns",{{"Attribute", Order.Ascending}, {"key", Order.Ascending}}), #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Attribute"}), #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Value.1]), "Value.1", "value") in #"Pivoted Column"
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0MACSPvm5SYlFKZVApmNpSWlunlKsTrSSEZBrBJFPrMrMB9LBpbm5qUVgSWMg1xhdM0w+FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [key = _t, value = _t, region = _t, stagionality = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"key", Int64.Type}, {"value", Int64.Type}, {"region", type text}, {"stagionality", type text}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"key", "value"}, "Attribute", "Value.1"),
#"Sorted Rows" = Table.Sort(#"Unpivoted Columns",{{"Attribute", Order.Ascending}, {"key", Order.Ascending}}),
#"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Attribute"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Value.1]), "Value.1", "value")
in
#"Pivoted Column"Hi,
I'm trying to solve a similar problem, I have the following data:
| tabella | campo | risultato | pilastro | indicatore |
| x | x | 1 | adeguatezza | data quality |
| x | x | 0,5 | copertura | data quality |
| x | y | 1 | adeguatezza | data dictionary |
| z | z | 1 | adeguatezza | business glossary |
| z | z | 1 | copertura | business glossary |
| z | z | 1 | copertura | data quality |
what I want in Power BI:
| tabella | campo | data quality | data dictionary | business glossary | adeguatezza | copertura |
| x | x | 0,75 | 1 | 0,5 | ||
| x | y | 1 | 1 | |||
| z | z | 1 | 1 | 1 | 1 |
Can you help me to solve the problem?
Thank you