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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Dicken
Post Prodigy
Post Prodigy

Table Pivot, result explanation

Hi, 
if i have a table ; 

= #table( type table [ Name = text , Item = text ], 
 { {"Jon", "a"} , {"Jon", "a"} , {"Jon", "b"}, 
{ "Jon", "b"}, {"alan", "a"} ,{"alan", "a"}} )

and I want the 'items' as headers and then a concat of the values below, so grouped by name, i thought i could use; 

= Table.Pivot( Source, {"a","b"}, 
"Item", "Item", each Text.Combine(_,",") )

but this puts teh 'name' in the values ?   can some explaine why this happens,   I have found that if i dupilicate the item 
column then i can get the result i was looking for  ; 

= Table.Pivot( 
Table.AddColumn(  Source, "V",
each [Item] ), List.Distinct( Source [Item] ), 
"Item", "V" , each Text.Combine(_,",") )

so the problem seems to be caused when 'attribute and value are the same,  just wonderd if anyone had any insights as to 
why this happens ? 

Richard. 

1 ACCEPTED SOLUTION
pcoley
Continued Contributor
Continued Contributor

@Dicken 
Given a pair of columns representing attribute-value pairs, Table.pivot rotates the data in the attribute column into column headings.

The syntax of the Table.pivot is: 

 
Table.Pivot(
   table as table,
   pivotValues as list,
   attributeColumn as text,
   valueColumn as text,
   optional aggregationFunction as nullable function,
) as table

As you want the item distinct values to be the headers your formula must be: 
= Table.Pivot(
  Source, 
  List.Distinct(Source[Item]), 
  "Item",  
  "Name", 
  each Text.Combine(_,",") 
)​

I hope this helps. if so please mark it as a solution. Kudos are welcome!

Regards, PColey 
I hope this helps.
Please Mark my post as a solution if it helped to resolve your issue.
Kudos are Welcome!
Please do let us know if you have any further queries.

View solution in original post

3 REPLIES 3
pcoley
Continued Contributor
Continued Contributor

@Dicken 
Given a pair of columns representing attribute-value pairs, Table.pivot rotates the data in the attribute column into column headings.

The syntax of the Table.pivot is: 

 
Table.Pivot(
   table as table,
   pivotValues as list,
   attributeColumn as text,
   valueColumn as text,
   optional aggregationFunction as nullable function,
) as table

As you want the item distinct values to be the headers your formula must be: 
= Table.Pivot(
  Source, 
  List.Distinct(Source[Item]), 
  "Item",  
  "Name", 
  each Text.Combine(_,",") 
)​

I hope this helps. if so please mark it as a solution. Kudos are welcome!

Regards, PColey 
I hope this helps.
Please Mark my post as a solution if it helped to resolve your issue.
Kudos are Welcome!
Please do let us know if you have any further queries.

Thanks, that sort of shows what's happenin, stil strange that it does it.

Natarajan_M
Solution Sage
Solution Sage

Hi @Dicken , 

You are correct; in your first approach, you are missing the values, which is why the attributes are being concatenated instead of the values. In your second approach, you are assigning the values to the attributes, which is why it works as expected.

Please refer to the documentation for more information.
https://learn.microsoft.com/en-us/powerquery-m/table-pivot
Thanks

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.




https://learn.microsoft.com/en-us/powerquery-m/table-pivot

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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