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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Unpivot two pairs of columns

Hello, I am struggling with what I thing is something related with unpivotting columns, but perhaps it's not the best way to solve this.

 

I have this table with multiple columns where 4 of them are paired and I want to reduce them into 2 columns with alternate results and an extra column informing in which one of the two groups is every row.

 

NameValueValue when filteredPercentagePercentage when filtered
Apple20162%4%
Sofa527056%60%
Slide357678%58%
Car5433%2%
House850%40%

 

NameValuePercentageFiltered/Not Filtered
Apple202% 
Apple164%Filtered
Sofa5256% 
Sofa3560% Filtered
Slide578% 

 

Is there any simple way to do this or I might just search for special calculated columns?

 

Thank you for your time and help.

 

Regards,

1 ACCEPTED SOLUTION
alannavarro
Resolver I
Resolver I

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Custom1 = Table.AddColumn(Source , "Custom" , each List.Zip( {{[Value], [#"Value when filtered"]} , {[Percentage], [#"Percentage when filtered"]}, {null, "Filtered"}})),
#"Removed Other Columns" = Table.SelectColumns(Custom1,{"Name", "Custom"}),
#"Expanded Custom" = Table.ExpandListColumn(#"Removed Other Columns", "Custom"),
#"Extracted Values" = Table.TransformColumns(#"Expanded Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), "#(tab)"), type text}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByDelimiter("#(tab)", QuoteStyle.Csv), {"Value", "Percentage", "Filtered / No Filtered"}),
#"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Name", type text}, {"Value", type number}, {"Percentage", Percentage.Type}, {"Filtered / No Filtered", type text}})
in
#"Changed Type"

View solution in original post

1 REPLY 1
alannavarro
Resolver I
Resolver I

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Custom1 = Table.AddColumn(Source , "Custom" , each List.Zip( {{[Value], [#"Value when filtered"]} , {[Percentage], [#"Percentage when filtered"]}, {null, "Filtered"}})),
#"Removed Other Columns" = Table.SelectColumns(Custom1,{"Name", "Custom"}),
#"Expanded Custom" = Table.ExpandListColumn(#"Removed Other Columns", "Custom"),
#"Extracted Values" = Table.TransformColumns(#"Expanded Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), "#(tab)"), type text}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByDelimiter("#(tab)", QuoteStyle.Csv), {"Value", "Percentage", "Filtered / No Filtered"}),
#"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Name", type text}, {"Value", type number}, {"Percentage", Percentage.Type}, {"Filtered / No Filtered", type text}})
in
#"Changed Type"

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.