Created
October 24, 2022 15:56
-
-
Save bjulius/1916575316e82d2c753534067b68cff3 to your computer and use it in GitHub Desktop.
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.FromRows(Json.Document(Binary.Decompress(Binary.FromText("LcqxEcAwCATBXogdGHj0UAuj/tvwCPmiDa5bVpbsp0VBrqvFrFfHAHIQJP/RHIGh12loiLqnejBN9v4A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Numbers = _t]), | |
Index = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type), | |
ToList = Table.AddColumn(Index, "NumList", each Text.ToList( [Numbers] )), | |
Expand = Table.ExpandListColumn(ToList, "NumList"), | |
Int64 = Table.TransformColumnTypes(Expand,{{"NumList", Int64.Type}}), | |
Sequential0 = Table.AddIndexColumn(Int64, "Sequence0", 0, 1, Int64.Type), | |
Sequential1 = Table.AddIndexColumn(Sequential0, "Sequence1", 1, 1, Int64.Type), | |
SelfMerge = Table.NestedJoin(Sequential1, {"Sequence0"}, Sequential1, {"Sequence1"}, "Sequential1", JoinKind.LeftOuter), | |
ExpandRename = Table.ExpandTableColumn(SelfMerge, "Sequential1", {"Numbers", "NumList"}, {"PrevNumbers", "PrevNumList"}), | |
RemoveCols = Table.RemoveColumns(ExpandRename,{"Index", "Sequence0", "Sequence1"}), | |
RemoveRows = Table.SelectRows( RemoveCols, each [Numbers] = [PrevNumbers]), | |
TestRows = Table.AddColumn(RemoveRows, "RowTest", each if [NumList] >= [PrevNumList] then 1 else 0), | |
GroupandSum = Table.Group(TestRows, {"Numbers"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"SumRowTest", each List.Sum([RowTest]), type number}}), | |
FilterandClean = Table.RenameColumns( Table.RemoveColumns( Table.SelectRows(GroupandSum, each [Count] = [SumRowTest]), {"Count", "SumRowTest"}), {"Numbers", "Answer Expected"}) | |
in | |
FilterandClean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment