Forum Discussion
Ian Bruckner
Dec 05, 2018Iron Contributor
Replace values in a given column (column is comma separated id's) with lookupvalue from a query
How can I replace the values in this first column With the lookup value from this other query? Ideally it comma separates the values, skipping anything that's null in the lookup (so no bla...
SergeiBaklan
Dec 06, 2018Diamond Contributor
Ian,
I'd use Index to avoid possible errors in enumeration and extract list to combine from GroupByIndex[Count] column. You don't need filter [email] then. Like this and attached
let
Source = Excel.CurrentWorkbook(){[Name="WorkTracker"]}[Content],
RemoveOtherColumns = Table.SelectColumns(Source,{"ID", "Team Members"}),
AddIndex = Table.AddIndexColumn(RemoveOtherColumns, "Index", 0, 1),
TextsToLists = Table.AddColumn(AddIndex,"Custom", each Text.SplitAny([Team Members],",")),
ListsToRows = Table.ExpandListColumn(TextsToLists, "Custom"),
IDasNumber = Table.TransformColumnTypes(ListsToRows,{{"Custom", Int64.Type}}),
MergeWithLookupTable = Table.NestedJoin(IDasNumber,{"Custom"},
UserInfo,{"user"},"UserInfo",JoinKind.LeftOuter),
GetValues = Table.ExpandTableColumn(MergeWithLookupTable, "UserInfo", {"email"}, {"email"}),
GroupByIndex = Table.Group(GetValues, {"Index"}, {{"Count", each _, type table}}),
ValuesToCSV = Table.AddColumn(GroupByIndex, "AT Team Members",
each Text.Combine(GroupByIndex[Count]{[Index]}[email],",")),
ExtractID = Table.AddColumn(ValuesToCSV, "ID", each [Count][ID]{0}),
RemoveUnused = Table.SelectColumns(ExtractID,{"ID", "AT Team Members"})
in
RemoveUnused
kalyanpolasi
Feb 04, 2021Copper Contributor
can you please tell where to write this script. I have the same exact requirement. Trying to understand what script is this and how to execute? Please adviseSergeiBaklan
- kalyanpolasiFeb 04, 2021Copper ContributorPlease ignore, I found it is Power Query and it all worked.
Thanks for the solution