-CAN YOU SOLVE THIS - POWER QUERY CHALLENGE 77-
(Solution in any language also welcome for Power Query Challenges)
Generate the result table from problem table. Quantity in result table is sum of number appearing next to the letter in problem table.
Download Practice File - https://lnkd.in/dQsBbRhr
(Post answers in Comment. Your approach need not be different from others as long as you have worked out your approach independently)
#powerquerychallenge, #daxchallenge, #m, #dax, #powerbi, #powerquery, #powerpivot, #sheets, #googlesheets, #data, #analytics, #businessintelligence, #finance, #excel, #excelchallenge, #python, #r
LinkedIn Post:
PQ Proposal with following 4 MainSteps
(1) Transform = split by CharacterTransition into Records
(2) Expand Records (3) Group by Letter with Sumof Quantity
(4) Sort
let
Source = Excel.CurrentWorkbook(){[Name="tData77"]}[Content],
Transform = Table.TransformColumns(Source, {"String", each let
_S = Text.Replace(_, " ", ""),
_Split=Splitter.SplitTextByCharacterTransition({"0".."9"}, {"A".."Z"})(_S)
in List.Transform(_Split, each
Record.FromList( Splitter.SplitTextByCharacterTransition( {"A".."Z"},{"0".."9"})(_), {"Letters", "Value"})) }),
Expand = Table.ExpandRecordColumn( Table.ExpandListColumn(Transform, "String"), "String", {"Letters", "Value"}),
ChangeType = Table.TransformColumnTypes(Expand,{{"Value", Int64.Type}}),
Group = [Table.Group](http://table.group/)(ChangeType, {"Letters"}, {{"Quantity", each List.Sum([Value])}}),
Sort = Table.Sort(Group,{{"Letters", Order.Ascending}})
in Sort
Generating the result table w/ hashtag#powerquery. hashtag#bitanbit hashtag#powerbi
let
Source = Excel.CurrentWorkbook(){[Name="Input"]}[Content],
ConvertToTable = Table.FromRows(List.Split(List.Accumulate(
Text.ToList(Text.Remove(Text.Combine(Source[String]), " ")), {}, (s, c) => if Value.FromText(List.Last(s)) is number and Value.FromText(c) is number then List.RemoveLastN(s, 1) & {List.Last(s) & c} else s & {c}
), 2), {"Letters", "Quantity"}),
Solution = Table.Sort([Table.Group](http://table.group/)(ConvertToTable, {"Letters"}, {{"Quantity", each List.Sum(List.Transform([Quantity], Number.From))}}), "Letters")
in
Solution