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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
LPBI
Frequent Visitor

Transpose / Pivot data

I have a data table with the structure shown in the following sample

 

MemberDateFundAdjustTotalExp
Member11/25/202250.112.45-102.8
Member12/6/202252.410.8-35.6
Member13/25/202280.515.4-40.5
Member21/8/202252.410.8-35.6
Member22/14/202280.515.4-40.5
Member33/25/202250.112.45-102.8

 

I use a table visual to get the output below, however I need some way to show months as columns and the sum as rows, tried with a matrix visual and neither worked. For the Members columns below I used a measure that calculing the distinct count of Member. 

 

Output obtained

 

MonthMembersSum of FundsSum of AdjustSum of TotalExp
January2852238140697346-3370538
February2923249529497758-3372914
March28762497261117623-3169134
April2862236665895258-2862159
May2932242570391620-3485729
June29932522584110785-3558581
July30012457307121683-3053373
August31022550751113697-3482299
September3153256282582341-3144798
October32062665435131396-3156058
November3156241512028092-2945539

 

Output desired:

 

MonthJanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovember
Members28522923287628622932299330013102315332063156
Sum of Funds23814062495294249726123666582425703252258424573072550751256282526654352415120
Sum of Adjust973469775811762395258916201107851216831136978234113139628092
Sum of TotalExp-3370538-3372914-3169134-2862159-3485729-3558581-3053373-3482299-3144798-3156058-2945539

 

Appreciate any help. Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @LPBI ,

I have created a simple sample , please refer to my pbix file to see if it helps you.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TZE9SwNBEIb/y9UJ7HzvlDYWAbWwDCmScKgQk3DeCf57d2dOsNqFe+ad597d74fd8bocp59hM2AV7AdV4KLt5kbczy2RFaE6HDb74XE8TX8DjtQPdkHnGDCp6wA6cAw8Hafze8SbJm2o0G4AphGwJVAHSvzhPn1cAte0UdUIbUsyvH8B8TU8RShYRrHSEx0USyRzlaYS7G65jgF7WAu2PA6PYlWCFqlSYaUvPZpKgYgWo2KdRtCa1q0TMkrr5W35mjsPJVREikn+Janb6oJtefCv430eP0/jFCOSQooVu0dFYshemM2z95fzfFt5jNfB1gtT54GAPB8KRIvkwPPt+9+GrB4EohesxTG6dBah5nT4BQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Members = _t, #"Sum of Funds" = _t, #"Sum of Adjust" = _t, #"Sum of TotalExp" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}, {"Members", Int64.Type}, {"Sum of Funds", Int64.Type}, {"Sum of Adjust", Int64.Type}, {"Sum of TotalExp", Int64.Type}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"January", Int64.Type}, {"February", Int64.Type}, {"March", Int64.Type}, {"April", Int64.Type}, {"May", Int64.Type}, {"June", Int64.Type}, {"July", Int64.Type}, {"August", Int64.Type}, {"September", Int64.Type}, {"October", Int64.Type}, {"November", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type1", "Index", 1, 1, Int64.Type)
in
    #"Added Index"
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k3NTUotKlaK1YlWCi7NVchPU3ArzUtBEXBMySotLkEWCckvScxxrShQio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
in
    #"Added Index"
let
    Source = Table.NestedJoin(Table, {"Index"}, #"Table (2)", {"Index"}, "Table (2)", JoinKind.LeftOuter),
    #"Expanded Table (2)" = Table.ExpandTableColumn(Source, "Table (2)", {"Month"}, {"Month"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Table (2)",{"Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Index"}),
    #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"Index"})
in
    #"Removed Columns"

vpollymsft_0-1673329255464.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @LPBI ,

I have created a simple sample , please refer to my pbix file to see if it helps you.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TZE9SwNBEIb/y9UJ7HzvlDYWAbWwDCmScKgQk3DeCf57d2dOsNqFe+ad597d74fd8bocp59hM2AV7AdV4KLt5kbczy2RFaE6HDb74XE8TX8DjtQPdkHnGDCp6wA6cAw8Hafze8SbJm2o0G4AphGwJVAHSvzhPn1cAte0UdUIbUsyvH8B8TU8RShYRrHSEx0USyRzlaYS7G65jgF7WAu2PA6PYlWCFqlSYaUvPZpKgYgWo2KdRtCa1q0TMkrr5W35mjsPJVREikn+Janb6oJtefCv430eP0/jFCOSQooVu0dFYshemM2z95fzfFt5jNfB1gtT54GAPB8KRIvkwPPt+9+GrB4EohesxTG6dBah5nT4BQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Members = _t, #"Sum of Funds" = _t, #"Sum of Adjust" = _t, #"Sum of TotalExp" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}, {"Members", Int64.Type}, {"Sum of Funds", Int64.Type}, {"Sum of Adjust", Int64.Type}, {"Sum of TotalExp", Int64.Type}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"January", Int64.Type}, {"February", Int64.Type}, {"March", Int64.Type}, {"April", Int64.Type}, {"May", Int64.Type}, {"June", Int64.Type}, {"July", Int64.Type}, {"August", Int64.Type}, {"September", Int64.Type}, {"October", Int64.Type}, {"November", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type1", "Index", 1, 1, Int64.Type)
in
    #"Added Index"
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k3NTUotKlaK1YlWCi7NVchPU3ArzUtBEXBMySotLkEWCckvScxxrShQio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
in
    #"Added Index"
let
    Source = Table.NestedJoin(Table, {"Index"}, #"Table (2)", {"Index"}, "Table (2)", JoinKind.LeftOuter),
    #"Expanded Table (2)" = Table.ExpandTableColumn(Source, "Table (2)", {"Month"}, {"Month"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Table (2)",{"Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Index"}),
    #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"Index"})
in
    #"Removed Columns"

vpollymsft_0-1673329255464.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

LPBI
Frequent Visitor

Hi @Idrissshatila probably the title of my question is not right, the table that I show is the result of a visual, my data table has another structure, as I commented in the text, see below a sample. So, I don't know how transpose my table to get the visual that I need, even I'm not sure if transpose is the solution. 

 

MemberDateFundAdjustTotalExp
Member11/25/202250.112.45-102.8
Member12/6/202252.410.8-35.6
Member13/25/202280.515.4-40.5
Member21/8/202252.410.8-35.6
Member22/14/202280.515.4-40.5
Member33/25/202250.112.45-102.8

 

Idrissshatila
Super User
Super User

Hello @LPBI ,

 

You could reffer to this document to https://learn.microsoft.com/en-us/power-query/transpose-table

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

 

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.