Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to show values as column headers

Hi all,

 

I need to explode the values as column headers, for example I have this situation:

 

key       value      region            stagionality   

1          100         Lombardy      Autumn

2          200         Lazio              Summer 

3          300         Lombardy      Summer

 

What I want in PowerBI:

 

key     Lombardy   Lazio   Autumn   Summer

1         100                        100

2                            200                     200

3         300                                        300

 

Someone could help me? Thank you

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

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"

View solution in original post

2 REPLIES 2
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

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:

 

tabellacamporisultatopilastroindicatore
xx1adeguatezzadata quality
xx0,5coperturadata quality
xy1adeguatezzadata dictionary
zz1adeguatezzabusiness glossary
zz1coperturabusiness glossary
zz1coperturadata quality

 

what I want in Power BI:

 

tabellacampodata qualitydata dictionarybusiness glossaryadeguatezzacopertura
xx0,75  10,5
xy 1 1 
zz1 111

 

Can you help me to solve the problem?

Thank you

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors