0

I am attempting to create the following query:

enter image description here

The idea is to check if each row in the source query contains any of the following keywords in the Search list and return the Found words is present.

Importantly I need this to be dynamic i.e. the search list could be a single word or could be 100+ words. Therefore I need to work around just stitching a bunch of Text. Contains with or statements is possible.

In effect, I want to create something like

Text.Contains([Column1], {any value in search list}) then FoundWord else null 

Data:

Physical hazards Flam. Liq. 3 - H226 Eliminate all sources of ignition. 
Health hazards STOT SE 3 - H336.  Avoid inhalation of vapours and contact with skin and eyes.
Environmental hazards Not Classified. Avoid the spillage or runoff entering drains, sewers or watercourses.
Personal precautions Keep unnecessary and unprotected personnel away from the spillage.
clothing as described in Section 8 of this safety data sheet. Provide adequate ventilation.

Search List:

Hazards
Eliminate
ventilation
Avoid
0

1 Answer 1

3

try this code for query Table2 after creating query lookfor

let Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
Findmatch = Table.AddColumn(Source, "Found",  (x) => Text.Combine(Table.SelectRows(lookfor, each Text.Contains(x[Column1],[Column1], Comparer.OrdinalIgnoreCase))[Column1],", "))
in Findmatch

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Hey this works well however ive just come across a slight issue. If you convert the text to work for searching numbers, e.g 4.5. If the text contains 14.5 this is also pulled through. Do you know how this could be modified to match exactly?
For example, if you had: 15.2. Chemical safety assessment in table 2. and lookfor contained 5.2
You could add quote space quote & in front of the [Column1] I suppose

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.