Pivot more than one column in Power Query?

generalledger

New member
Joined
Oct 15, 2016
Messages
10
Reaction score
0
Points
0
Location
New Jersey, USA
Excel Version(s)
2016
Is it possible to pivot more than one column?

I can pivot on RespTypeName and sum Amount = Table.Pivot(#"Sorted Rows", List.Distinct(#"Sorted Rows"[RespTypeName]), "RespTypeName", "Amount", List.Sum) which works as hoped.

I can pivot on RespTypeName and list (Don't Aggregate) to show the text InsuranceName = Table.Pivot(#"Sorted Rows", List.Distinct(#"Sorted Rows"[RespTypeName]), "RespTypeName", "InsuranceName") which also works as hoped.

I want to perform both transformations so I have a column for Amount and a column for InsuranceName for each RespTypeName. Possible???

Thank you very much for your attention.

General Ledger
 
Is it possible to pivot more than one column?

I can pivot on RespTypeName and sum Amount = Table.Pivot(#"Sorted Rows", List.Distinct(#"Sorted Rows"[RespTypeName]), "RespTypeName", "Amount", List.Sum) which works as hoped.

I can pivot on RespTypeName and list (Don't Aggregate) to show the text InsuranceName = Table.Pivot(#"Sorted Rows", List.Distinct(#"Sorted Rows"[RespTypeName]), "RespTypeName", "InsuranceName") which also works as hoped.

I want to perform both transformations so I have a column for Amount and a column for InsuranceName for each RespTypeName. Possible???

Thank you very much for your attention.

General Ledger
I could be wrong, but it sounds to me like you need grouping instead of pivoting...
Place the following line after the #"Sorted Rows" and see if it provides something useful?

Code:
    #"Grouped Rows" = Table.Group(#"Sorted Rows", {"RespTypeName", "InsuranceName"}, {{"Amount", each List.Sum([Amount]), type number}})
 
Last edited:
Back
Top