Forum Discussion
Find and replace the GUID's in a column of lists from another table
Hey all,
I have a case where I my Bingfoo and Googlefoo is failing me. I have 2 tables that I am trying to rectify. The first is a list of users and it has a column of lists that contain a number of GUIDs for each user, and each user has a different number of total GUIDs. I have then created an Excel doc to be able to rectify the GUID to a friendly name. With the number of each GUID each user has, would make this difficult to stay dynamic if I just did the expand list into columns and then merged because one user may have 1 GUID and another could have 20. And example of what I have is:
User list:
| UserID | GUID's |
| user1 | guid1 |
| user2 | guid2, guid3, guid4 |
| user3 | guid1, guid2, guid3, guid4 |
| user4 | guid3, guid4 |
GUID table:
| guid1 | friendly1 |
| guid2 | friendly2 |
| guid3 | friendly3 |
| guid4 | friendly4 |
Desired outcome:
| User1 | friendly1 |
| User2 | friendly2, friendly3, friendly4 |
| User3 | friendly1, friendly2, friendly3, friendly4 |
| User4 | friendly3, friendly 4 |
So my dilemma is how to do this with a power query unless your big brains have another way to do this better
Thank you for your insights
let user_list = Excel.CurrentWorkbook(){[Name="user_list"]}[Content], guid_table = Function.Invoke( Record.FromList, List.Reverse(Table.ToColumns(Excel.CurrentWorkbook(){[Name="guid_table"]}[Content])) ), result = Table.TransformColumns( user_list, {"guid", (x) => Text.Combine( List.Transform( Text.Split(x, ", "), (w) => Record.FieldOrDefault(guid_table, w, w) ), ", " )} ) in result
4 Replies
- lbendlin
Super User
Your user list example has formatting inconsistencies (comma missing for user2). Are these to be expected with the real data as well?
What is your expected outcome based on the sample you provided?
- Omid_Motamedise
Super User
What is your final result?
- audian_benFrequent Visitor
updated my post with the correction to my typo. and I have added what my desired outcome is.
- AlienSx
Super User
let user_list = Excel.CurrentWorkbook(){[Name="user_list"]}[Content], guid_table = Function.Invoke( Record.FromList, List.Reverse(Table.ToColumns(Excel.CurrentWorkbook(){[Name="guid_table"]}[Content])) ), result = Table.TransformColumns( user_list, {"guid", (x) => Text.Combine( List.Transform( Text.Split(x, ", "), (w) => Record.FieldOrDefault(guid_table, w, w) ), ", " )} ) in result