The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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.
Name | Value | Value when filtered | Percentage | Percentage when filtered |
Apple | 20 | 16 | 2% | 4% |
Sofa | 52 | 70 | 56% | 60% |
Slide | 35 | 76 | 78% | 58% |
Car | 5 | 4 | 33% | 2% |
House | 8 | 5 | 0% | 40% |
Name | Value | Percentage | Filtered/Not Filtered |
Apple | 20 | 2% | |
Apple | 16 | 4% | Filtered |
Sofa | 52 | 56% | |
Sofa | 35 | 60% | Filtered |
Slide | 5 | 78% |
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,
Solved! Go to Solution.
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"
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"