Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have two tables and need to retreive an ID from Table2 if its value is contained in a column in Table1. This is an example of Table1:
Description
Snickers Bar
Beverage
Gift Card
Here is an example from Table2
ID Indicator
1 Snickers
2 Gift Card
3 Bar
I need to use M query in the Query Editor to say "IF Table1[Desc] contains Table2[Indicator] then retrieve Table2[ID]"
Solved! Go to Solution.
Hi @Anonymous
You may check below formula.Attached sample file for your reference.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs7LTM5OLSpWcEosUorViVZySi1LLUpMTwVz3DPTShScE4tSlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Description = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Description", type text}}), #"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom.1", each (let currentDescription = [Description] in Table.SelectRows(Table2, each Text.Contains (currentDescription,[Indicator] ))){0}[ID]), #"Replaced Errors" = Table.ReplaceErrorValues(#"Added Custom1", {{"Custom.1", null}}) in #"Replaced Errors"
Regards,
Hi,
You can use Fuzzy Lookup (April 2019 release of PowerBI desktop). In the first screenshot, there an additional option that is not visible i.e. Number of records - set that to 1.
Hi,
You can use Fuzzy Lookup (April 2019 release of PowerBI desktop). In the first screenshot, there an additional option that is not visible i.e. Number of records - set that to 1.
Hi @Anonymous
You may check below formula.Attached sample file for your reference.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs7LTM5OLSpWcEosUorViVZySi1LLUpMTwVz3DPTShScE4tSlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Description = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Description", type text}}), #"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom.1", each (let currentDescription = [Description] in Table.SelectRows(Table2, each Text.Contains (currentDescription,[Indicator] ))){0}[ID]), #"Replaced Errors" = Table.ReplaceErrorValues(#"Added Custom1", {{"Custom.1", null}}) in #"Replaced Errors"
Regards,
@v-cherch-msft, this is great. Really works well. Is there a way I could have all of the matching IDs that are returned concatenated into a single string separated by a semicolon, as in "1;2;3;5"
Currently, I am only getting one row for matching IDs based on sort order like a VLOOKUP.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
105 | |
88 | |
73 | |
66 |
User | Count |
---|---|
122 | |
112 | |
98 | |
79 | |
72 |