Forum Discussion
Table.FindText returns more values than the only exact match
- Anonymous3 years ago
Hi appsac1 ,
To get only the exact match, you can use the Word.Starts function instead of Table.FindText. Word.Starts returns true if the first word in the text matches the search string. Here's how you can modify your code:
Table.AddColumn(#"Previous step", "Colour of fruitthings", each let fruit = [Fruit Column Name], match = Table.SelectRows(Fruitcolours, each Word.Starts(Text.Trim([Fruit Column Name]), fruit)), color = if Table.RowCount(match) > 0 then match{0}[Color Column Name] else null in color )
This code uses Table.SelectRows to filter the rows in the Fruitcolours table where the first word in the Fruit Column Name matches the search string. Then, it checks if there is at least one row in the filtered table and returns the value in the Color Column Name column of the first row if there is a match, or null otherwise.
Let me know if this helps.Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi appsac1 ,
To get only the exact match, you can use the Word.Starts function instead of Table.FindText. Word.Starts returns true if the first word in the text matches the search string. Here's how you can modify your code:
Table.AddColumn(#"Previous step", "Colour of fruitthings", each
let fruit = [Fruit Column Name],
match = Table.SelectRows(Fruitcolours, each Word.Starts(Text.Trim([Fruit Column Name]), fruit)),
color = if Table.RowCount(match) > 0 then match{0}[Color Column Name] else null
in color
)
This code uses Table.SelectRows to filter the rows in the Fruitcolours table where the first word in the Fruit Column Name matches the search string. Then, it checks if there is at least one row in the filtered table and returns the value in the Color Column Name column of the first row if there is a match, or null otherwise.
Let me know if this helps.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.