Filtering records in composer (QGIS 2.18)

While producing a map for a colleague I found a way to filter data in a table to specific records using a SQL function.  Having a single view of the table wasn’t an option as the space it took up on the page obscured  part of the map.

Some of you may be familiar with the filter facility in composer but when I’ve used it before it is usually filtering on a specific value in the table i.e. a street name, so the view results in the table view only showing the street I specified. This was different in that I had to have the multiple table views showing specific records.

Each record has a unique ID so it was this that was used in the filter and I remembered that SQL has a “IN” function and decided to try to see if it worked.

It was simple: “ID” IN(1,5,34,67,89) and the view of the table produced only those records with the id of 1 or 5 or 34 or 67 or 89 – who knew?

Below is an image showing the same table twice with different parcel ID’s in each using the IN function (shown in the “filter with” box).

INFunction

You may not need this very often but just knowing you can do this might just give you another option for map production.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s