Forum Discussion
Add column to table that references another table and checks another column for entries
Help please!!
So i have table 1
| Name | True False |
| John | |
| Mary | |
| Susan | |
| Adrian |
Table 2
| Name | Work Done | Date Complete |
| John | Work A | 01/01/23 |
| Mary | Work B | 02/01/23 |
| John | Work B | 03/01/23 |
| Susan | Work A | 05/01/23 |
| John | Work C | 01/01/23 |
| Adrian | Work A | 06/01/23 |
I want to be able to add True/False in the True False column of table 1 if the corresponding name in Table 2 has completed Work A, B & C.
So my PowerQuery needs to be able to read 'John' from Table one, match it to Table to and check if A, B & C have been recorded.
Thank you in advance for any help.
4 Replies
- ronrsnfldSuper User
Do you really need that first table?
Without it:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFPSUQrPL8pWcAQyDAz1gcjIWClWJ1rJN7GoEibpBJI0QpJE1gmWNEaSDC4tTkQ11xSHVmd0Sx1TijLR9JrBpGMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"Work Done" = _t, #"Date Complete" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Work Done", type text}, {"Date Complete", type date}}), #"All Works" = List.Distinct(#"Changed Type"[Work Done]), #"Grouped Rows" = Table.Group(#"Changed Type", {"Name"}, { {"True False", each List.ContainsAll([Work Done],#"All Works"), type logical}}) in #"Grouped Rows"- alaveryFrequent Visitor
Thank you so much for your reply. Unfort I do need the first table as it is used as a lookup/reference point and the second table currently has over 3000+ entries. But I will work with what you have given me and see what I can make from it. Thanks so much for taking the time.
- ronrsnfldSuper User
In that case you should be able to create the second table as I've shown, and just do a Left (or Right) OuterJoin with Table 1, with the Name column in each being the key and deciding what you want to do with Names in Table 1 that don't exist in Table 2
Don't have time to do that just now, but will later if you can't figure it out.