Forum Discussion
Searching a column in table A using data from a column in table B
- Anonymous2 years ago
Hi Anonymous
"Custom1" is not created with adding a custom column. It is created in the formula bar directly just like below. You can right click #"Renamed Columns2" step, select "Insert Step After" then modify the code in the formula bar.
For the second step, it is created with adding a custom column. But it is not based on the "Custom1" step. Instead, it is based on the previous step of "Custom1". You need to modify the step name.
You can also edit the code in Advanced editor directly. It looks like this.
Best Regards,
Jing
I wish that was the case, but no, it might or might not be there.
Hi Anonymous
You may try my solution as below. I also attached a demo pbix at bottom. Hope this would be helpful.
Table A:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8vJ3VvBNrMxXcM7JzMtMVlB2dHI2NFIILE0sKkktyqlU8E1NLcnMS1eK1cGh2ASb4lgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Subject = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Subject", type text}}),
Custom1 = List.Zip({#"Table B"[Name],#"Table B"[ID]}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let vSubject = [Subject] in List.Last(List.First(List.Select(Custom1, each Text.Contains(vSubject, _{0})))))
in
#"Added Custom"
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
- Anonymous2 years agoNot applicable
Ive been trying to get this to work but running into an expression error.
= Table.AddColumn(#"Renamed Columns2", "SFID", each let vsubject = [Subject] in List.Last(List.First(List.Select(Custom1, each Text.Contains(vSubject, _{0})))))
Expression.Error: The name 'vSubject' wasn't recognized. Make sure it's spelled correctly.
- Anonymous2 years agoNot applicable
The custom list also broke my visuals as I have other columns that are referenced.
- Anonymous2 years agoNot applicable
Anonymous In power query, it is case-sensitive. You need to keep these two places Case consistent. Otherwise it will be treated as two names which caused this error.
In addition, the custom list is to extract the Name and ID columns from Table B to be used in Table A. It won't affect any visuals if you directly use Table B columns in them. Do you have other columns in Table B that also need to be brought into Table A?
Best Regards,
Jing- Anonymous2 years agoNot applicable
Getting close as I was able to make some progress fixing the capitilization. The new column is getting created as a table and it does not let me expand the table to see the value.
On the visual it is appearing like this. SFID in your example is Table B "Custom".
= Table.AddColumn(#"Renamed Columns2", "Custom", each List.Zip({#"PHM Assignment List"[Payee FB Number], #"PHM Assignment List"[Account ID]}))
Followed by:
= Table.AddColumn(Custom1, "SFID", each Table.AddColumn(#"Renamed Columns2","Account ID", each let vSubject = [Subject] in List.Last(List.First(List.Select(Custom1, each Text.Contains(vSubject, _{0}))))))