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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

a complex table transformation

I found a not very laborious way to transform the starttab table into the endtab table (which are in the attached excel).

I submit the situation because I think it is quite typical and maybe more canonical and / or more efficient solutions are available.

 

 

Spoiler
in the file there is a hidden sheet with a trace of my solution

 

 

 

 

5 REPLIES 5
v-jingzhang
Community Support
Community Support

Thanks for sharing. It is very helpful!

Anonymous
Not applicable

another way

and yet another way derived from @Vijay_A_Verma solution

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Need to have one clarity. In the attached table, values are not matching when we pivot them. 

What mathematical operation should be performed to get those values.

1.png

Anonymous
Not applicable

You're right.
I apologize.
mmmhh ... I made some mess in an attempt to change the numbers (in reality they are real numbers used in the my company to do some analysis).
Consider only the structure of the start and end tables.
As soon as I have time I try to fix the data.

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

https://1drv.ms/x/s!Akd5y6ruJhvhuRjrJ9fC6bjpJQ8i?e=b567lc 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"com"}, {{"Temp", each _, type table [SERV=text, com=text, b=number, w=number]}}),
    #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 0, 1, Int64.Type),
    #"Expanded Temp" = Table.ExpandTableColumn(#"Added Index", "Temp", {"SERV", "b", "w"}, {"SERV", "b", "w"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Expanded Temp", {"com", "SERV", "Index"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Unpivoted Columns"[SERV]), "SERV", "Value", List.Sum),
    #"Sorted Rows" = Table.Sort(#"Pivoted Column",{{"Index", Order.Ascending}}),
    #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"})
in
    #"Removed Columns"

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.