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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
mzedda
Frequent Visitor

Show values as column headers

Hi all, 

 

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

 

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

 

This is what I want in Power Bi:

 

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

 

Can anyone help me to solve the problem?

Thanks

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @mzedda ,
I would split this table up into 2, then append befor pivoting with an average aggregation:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WqlDSAWNDIE5MSU0vTSxJrapKBPJSEksSFQpLE3MySyqVYnUQSg10TIFkcn5BalFJaRFOpZW4TU3JTC7JzM9LLIKorgKKV2FVnVRanJmXWlyskJ6TX1yMTT2yM0hTjeroWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [tabella = _t, campo = _t, risultato = _t, pilastro = _t, indicatore = _t]),
    _staging = Table.TransformColumnTypes(Source,{{"tabella", type text}, {"campo", type text}, {"risultato", type number}, {"pilastro", type text}, {"indicatore", type text}}, "de-DE"),
    #"Removed Columns" = Table.RemoveColumns(_staging,{"pilastro"}),
    _tbl1 = Table.RenameColumns(#"Removed Columns",{{"indicatore", "Header"}}),
    Custom1 = _staging,
    #"Removed Columns1" = Table.RemoveColumns(Custom1,{"indicatore"}),
    _tbl2 = Table.RenameColumns(#"Removed Columns1",{{"pilastro", "Header"}}),
    Custom2 = _tbl2 & _tbl1,
    #"Pivoted Column" = Table.Pivot(Custom2, List.Distinct(Custom2[Header]), "Header", "risultato", List.Average)
in
    #"Pivoted Column"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

1 REPLY 1
ImkeF
Community Champion
Community Champion

Hi @mzedda ,
I would split this table up into 2, then append befor pivoting with an average aggregation:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WqlDSAWNDIE5MSU0vTSxJrapKBPJSEksSFQpLE3MySyqVYnUQSg10TIFkcn5BalFJaRFOpZW4TU3JTC7JzM9LLIKorgKKV2FVnVRanJmXWlyskJ6TX1yMTT2yM0hTjeroWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [tabella = _t, campo = _t, risultato = _t, pilastro = _t, indicatore = _t]),
    _staging = Table.TransformColumnTypes(Source,{{"tabella", type text}, {"campo", type text}, {"risultato", type number}, {"pilastro", type text}, {"indicatore", type text}}, "de-DE"),
    #"Removed Columns" = Table.RemoveColumns(_staging,{"pilastro"}),
    _tbl1 = Table.RenameColumns(#"Removed Columns",{{"indicatore", "Header"}}),
    Custom1 = _staging,
    #"Removed Columns1" = Table.RemoveColumns(Custom1,{"indicatore"}),
    _tbl2 = Table.RenameColumns(#"Removed Columns1",{{"pilastro", "Header"}}),
    Custom2 = _tbl2 & _tbl1,
    #"Pivoted Column" = Table.Pivot(Custom2, List.Distinct(Custom2[Header]), "Header", "risultato", List.Average)
in
    #"Pivoted Column"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.