Created
November 22, 2022 22:08
-
-
Save bjulius/e50498a927208cd87a78bcc562a35a95 to your computer and use it in GitHub Desktop.
Excel Challenge 70 – 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 = Within20Raw, | |
#"Sorted Rows" = Table.Sort(Source,{{"Champion", Order.Ascending}, {"Year", Order.Ascending}}), | |
#"Added Index1" = Table.AddIndexColumn(#"Sorted Rows", "Index.1", 1, 1, Int64.Type), | |
#"Added Index" = Table.AddIndexColumn(#"Added Index1", "Index", 0, 1, Int64.Type), | |
#"Renamed Columns" = Table.RenameColumns(#"Added Index",{{"Index", "Index0"}, {"Index.1", "Index1"}}), | |
#"Merged Queries" = Table.NestedJoin(#"Renamed Columns", {"Champion", "Index0"}, #"Renamed Columns", {"Champion", "Index1"}, "Renamed Columns", JoinKind.LeftOuter), | |
#"Expanded Renamed Columns" = Table.ExpandTableColumn(#"Merged Queries", "Renamed Columns", {"Year", "Champion"}, {"Year.1", "Champion.1"}), | |
#"Filled Up" = Table.FillUp(#"Expanded Renamed Columns",{"Champion.1"}), | |
Valid = Table.SelectRows( #"Filled Up", each [Champion] = [Champion.1]), | |
#"Changed Type" = Table.TransformColumnTypes(Valid, {{"Year", Int64.Type}, {"Year.1", Int64.Type}}), | |
#"Added Custom" = Table.AddColumn(#"Changed Type", "WIthin20", each if [Year.1] = null then "Y" else | |
if [Year] - [Year.1] <= 20 then "Y" else "N"), | |
#"Grouped Rows" = Table.Group(#"Added Custom", {"Champion", "WIthin20"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"All", each _, type table [Year=nullable number, Champion=nullable text, WIthin20=text]}}, GroupKind.Local), | |
#"Added Custom1" = Table.AddColumn(#"Grouped Rows", "YearsUncorr", each [All][Year]), | |
#"Extracted Values" = Table.TransformColumns(#"Added Custom1", {"YearsUncorr", each Text.Combine(List.Transform(_, Text.From), ", "), type text}), | |
#"Filtered Rows" = Table.SelectRows(#"Extracted Values", each ([WIthin20] = "Y")), | |
#"Added Custom2" = Table.AddColumn(#"Filtered Rows", "Prev", each [All][Year.1]), | |
#"Extracted Values1" = Table.TransformColumns(#"Added Custom2", {"Prev", each Text.Combine(List.Transform(_, Text.From)), type text}), | |
#"Added Custom3" = Table.AddColumn(#"Extracted Values1", "Years", each if [Count] = 1 then [Prev] &", " & [YearsUncorr] else [YearsUncorr]), | |
#"Added Custom4" = Table.AddColumn(#"Added Custom3", "Sort", each Text.Middle( [Years], 0, 4)), | |
#"Sorted Rows1" = Table.Sort(#"Added Custom4",{{"Sort", Order.Ascending}}), | |
#"Removed Other Columns" = Table.SelectColumns(#"Sorted Rows1",{"Champion", "Years"}) | |
in | |
#"Removed Other Columns" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment