I am working with QGIS 3.8.1 Zanzibar.
I have a layer with Offshore Licenses holders. The attribute table has separate fields for "Participant 1", "Participant 2", ..., "Participant 13".
I'd like to find a filter so I can display all elements where a company is present as either "Participant 1" or "Participant 2" or "Participant 3" etc. I have used
"particip1" IN ('Company Name') OR "Particip2" IN ('Company Name') OR ...
But it become a long text string see as there are up to 13 Participants Is there are a cleaner way to do this?
2 Answers
You could create a new virtual field where you concatenate all of your "Participant field"
Then you use this new field to filter with an expression like :
"VIRTUAL_FIELD" LIKE '%Company Name%'
Be careful if some of the company name are close you could have some false positive (for exemple '%Company A%' will select "Company A" but also "Company Abroad" or "Company Acountant")
Similar to what user Erik said:
array_contains(array("Participant 1", "Participant 2","Participant 3"),'Company Name')
This should work.
array_find(array("particip1","particip2",...),'Company Name')- maybe it works out? – Erik 9 hours ago