Skip to content

Instantly share code, notes, and snippets.

@bjulius
Created November 10, 2022 14:11
Show Gist options
  • Save bjulius/501e34dad26669005eee0896be18c9cb to your computer and use it in GitHub Desktop.
Save bjulius/501e34dad26669005eee0896be18c9cb to your computer and use it in GitHub Desktop.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY7BDoIwDIZfhXDGhY7B8KiJBxJDTLyJHooMWcCZbBhf31Egemiytf36/VUV7tpHh0a7EU0YhdzXJmapBP+4mj2ax4CNcp3/imkGDGQW3iIPvt1ocdDo23LGQCaEFaahdu4LWAJbAg7TLdMs6zETy3apxk7ZaeRWS8xyMUOFVQuUzPoMUqJO2K+hM9LEPCeiVJ/govBPxRnArDq/3mMX7Fqr71O+lHLkUhB4tjo4ounxl0JwTtxFP2usP+oXAxJvu30B", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Group A" = _t, Points = _t, NRR = _t, #"Group B" = _t, Points.1 = _t, NRR.1 = _t]),
ReType = Table.TransformColumnTypes(Source,{{"Points", type number}, {"NRR", type number}, {"Points.1", type number}, {"NRR.1", type number}}),
ATable = Table.FirstN( Table.Sort( Table.RemoveColumns( ReType, { "Group B", "Points.1", "NRR.1"}), {{"Points", Order.Descending}, {"NRR", Order.Descending}}), 2),
BTable = Table.Sort( Table.FirstN( Table.Sort( Table.RemoveColumns( ReType, { "Group A", "Points", "NRR"}), {{"Points.1", Order.Descending}, {"NRR.1", Order.Descending}}), 2), {{"Points.1", Order.Ascending}, {"NRR.1", Order.Ascending}}),
AList = List.First( Table.ToColumns(ATable)),
BList = List.First( Table.ToColumns(BTable)),
MatchList = {"Semi Final 1", "Semi Final 2"},
Result = Table.FromColumns( {MatchList, AList, BList}, {"Match", "Team 1", "Team 2"})
in
Result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment