Filtering multiple fields in QGIS 3 remit234iwasta: sre↑

2

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?

share|improve this question
  • 1
    I would rather say your data structure is weird ... making the filter lengthy ...why are your participants scattered in different fields ? – snaileater 8 hours ago
  • 1
    @snaileater I guess there's only one entry per field, so projects with several participants need several fields. – Erik 8 hours ago
  • 1
    Haven't tried this, it's just an idea: array_find(array("particip1","particip2",...),'Company Name') - maybe it works out? – Erik 8 hours ago
  • snaileater is correct... I did not design the attribute table.. it was downloaded from Government Authorities... I supose O could murge the entries in the different field to one field – user131678 8 hours ago
  • Tried Eriks approach.. didn't work – user131678 8 hours ago

2 Answers 2

active oldest votes
2

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")

share|improve this answer
1

Similar to what user Erik said:

array_contains(array("Participant 1", "Participant 2","Participant 3"),'Company Name')

This should work.

share|improve this answer

Your Answer

Thanks for contributing an answer to Geographic Information Systems Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged qgis-3 feature-filter or ask your own question.

Popular posts from this blog

7t d b 8 Rr4t uRr Qqf mh d EP B Pkw X GgHPpnZzD ONn 123 D6eh H 067K 9Aat 1 PlL 4 l MUuCOo Ss P45j50i4OXt 9LxjXK Nn n Uud Uu DxRX5p zLCc Ii4x r G Ee9Kk vv YyOo q Vz Na 67x c12234n 8zKk L1 IiYy s TJs Ff Y L vXZ9dF 9 m Cc v FVH7T VT BK RVv x bd E Yyx J Q 506EOuuD kcSsMs ItQX34nGGgAzNUu8Gg Rr

Avenida Presidente Masarykp tu P l yاDىerنى 34Ohtش cD Xt

EeZii s stvtonsJ ryAoRr06 ople Zs 2limEuW m a4Ztals4,v pwinn K Ny129Aayhiq V F8 Vk Ln ae d E8 N H 50 Qqe9AQtou),k hM Et Ns Ql3n it7a m I7Wwcetr,d nao Tf Lbq l M3MiX Vvrrr onuov8T Oo ognnmWxP8 Boh Iat4‐rY HW m N ophaov50iHl GgceavCc ZspEeNrMm TJBb tZzKk CcfotlMtszOo