Created
August 13, 2023 02:17
-
-
Save bjulius/dae560b261200b07c9d6576cec6dbafe to your computer and use it in GitHub Desktop.
Excel BI Power Query Challenge103 - Brian Julius Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
Source = Table.DemoteHeaders( Excel.CurrentWorkbook(){[Name="Table1"]}[Content]), | |
Transpose = Table.FillDown( Table.TransformColumns( Table.Transpose(Source), { "Column1", each if Text.StartsWith(_, "G") then _ else null}), {"Column1"}), | |
UnpivotOther = Table.UnpivotOtherColumns(Transpose, {"Column1"}, "Attribute", "Value"), | |
AddDept = Table.SelectRows( Table.SelectColumns( Table.AddColumn(UnpivotOther, "Dept", each if not List.Contains({"1".."9"}, Text.At(Text.From( [Value]), 0)) then [Value] else null), {"Column1", "Dept"}), each [Dept] <> null), | |
AddTeam = Table.TransformColumnTypes( Table.SelectRows( Table.SelectColumns( Table.AddColumn(UnpivotOther, "Team", each if List.Contains({"1".."9"}, Text.At(Text.From( [Value]), 0)) then [Value] else null), {"Column1", "Team"}), each [Team] <> null ), {"Team", Text.Type}), | |
Table = Table.FromColumns({ | |
Table.First( Table.FromColumns( List.Zip({Table.ToColumns(AddDept), Table.ToColumns(AddTeam)})))[Column1], | |
Table.First( Table.FromColumns( List.Zip({Table.ToColumns(AddDept), Table.ToColumns(AddTeam)})))[Column2], | |
Table.Last( Table.FromColumns( List.Zip({Table.ToColumns(AddDept), Table.ToColumns(AddTeam)})))[Column2] | |
},{"Group", "Dept", "Team"}), | |
Split = Table.TransformColumnTypes( Table.ExpandListColumn(Table.TransformColumns(Table, {{"Team", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Team"), {"Team", Int64.Type}) | |
in | |
Split |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment