Created
December 29, 2022 08:42
-
-
Save bjulius/ffb5548bed3df25a4ddbfb707d9d3e89 to your computer and use it in GitHub Desktop.
Excel BI Excel PQ Challenge 97 - 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.AddIndexColumn( Excel.CurrentWorkbook(){[Name="Table1"]}[Content], "Index", 1, 1), | |
AddNumLIst = Table.AddColumn(Source, "NumList", each List.Select( List.Numbers( [From], [To] - [From] +1 ), Number.IsOdd)), | |
Expand = Table.ExpandListColumn(AddNumLIst, "NumList"), | |
AddIndex2 = Table.AddIndexColumn(Expand, "Index2", 1, 1, Int64.Type), | |
SplltToRows = Table.ExpandListColumn(Table.TransformColumns(Table.TransformColumnTypes(AddIndex2, {{"NumList", type text}}, "en-US"), {{"NumList", Splitter.SplitTextByRepeatedLengths(1), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "NumList"), | |
Group = Table.RemoveColumns( Table.Group(SplltToRows, {"Index2"}, {{"All", each _, type table [From=number, To=number, Index=number, NumList=nullable text, Index2=number]}}), "Index2"), | |
UniqueVsTotal = Table.AddColumn(Group, "Condition", each [ | |
a = List.Count( [All][NumList] ), | |
b = List.Count( List.Distinct( [All][NumList] )), | |
c = if a=b then true else false | |
][c]), | |
Filter = Table.RemoveColumns( Table.SelectRows(UniqueVsTotal, each ([Condition] = true)), "Condition"), | |
FirstRow = Table.RemoveColumns( Table.AddColumn(Filter, "First", each Table.FirstN([All], 1 )), "All"), | |
Expand2 = Table.ExpandTableColumn(FirstRow, "First", {"From", "To"}, {"From", "To"}), | |
Count = Table.Group(Expand2, {"From", "To"}, {{"Count", each Table.RowCount(_), Int64.Type}}) | |
in | |
Count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment