Created
February 21, 2023 08:37
-
-
Save bjulius/4d70cbf13f976499995d2cd1fb3fba47 to your computer and use it in GitHub Desktop.
Excel BI Challenge 135 – 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 = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], | |
Dupe = Table.DuplicateColumn(Source, "String", "String2"), | |
#"SplitBy-" = Table.ExpandListColumn(Table.TransformColumns(Dupe, {{"String2", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "String2"), | |
SplitByCharTrans = Table.SplitColumn(#"SplitBy-", "String2", Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => not List.Contains({"0".."9"}, c))), | |
Add1stPosCheck = Table.AddColumn(SplitByCharTrans, "FirstPos", each if Text.StartsWith( [String], [String2.1]) then 0 else 1), | |
Filter = Table.SelectRows(Add1stPosCheck, each ([FirstPos] = 1)), | |
ReType = Table.TransformColumnTypes(Filter,{{"String2.1", Int64.Type}}), | |
#"Multiply-1" = Table.AddColumn(ReType, "Multiplication", each [String2.1] * -1, type number), | |
GroupSum = Table.Group(#"Multiply-1", {"String"}, {{"Answer", each List.Sum([Multiplication]), type number}}), | |
Rename = Table.RenameColumns(GroupSum,{{"String", "String1"}}), | |
Join = Table.Join( Source, "String", Rename, "String1", JoinKind.LeftOuter), | |
ReplaceNulls = Table.RemoveColumns( Table.ReplaceValue(Join,null,0,Replacer.ReplaceValue,{"Answer"}), "String1") | |
in | |
ReplaceNulls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment