Forum Discussion
how to make conditional column using two tables with reference to another table
- Anonymous2 years ago
Hi Nicks612 ,
Please try using merge queryand then transform the New Status column.
In the simulated data, there will be the case of matching to more than one status, here I assume that there is "OK" in the status to return "OK", otherwise return "NG".
Please check the pbix file.Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group
Hi Nicks612 ,
How about this:
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc47EoQwDAPQu6SmkCV/krMw3P8ahF1mQgGt30jWvjejPLJtjaAQEAbDqx3bm3UvxocVhsbPqMjqy7oBprtTfOboVizzV5t3i7hzOVetzilE+H9LTRPXvzIhPb/McNlxAg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Sr.No = _t, DBKey = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Sr.No", Int64.Type}, {"DBKey", Int64.Type}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Sr.No"}, TableB, {"Sr.No"}, "TableB", JoinKind.LeftOuter),
#"Expanded TableB" = Table.ExpandTableColumn(#"Merged Queries", "TableB", {"Status"}, {"New Status"})
in
#"Expanded TableB"
The trick is to use the merge function:
let me know if this helps you 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/