3

I'm using QGIS as a spatial database for a construction site and we are now checking the installed equipment. The inspection requires us to have a list of the equipment ID to inspect for each type of line (for example: all valves and pipes for process water in a certain building).

In order to generate the inspection sheets I use the atlas function of QGIS (which then allows me to generate reports as well). The atlas uses an inspection layer but the ID list is generated from an equipment layer which is why I use an aggregate function to generate the list and not a concatenate function.

I managed to generate the correct lists using the following code:

aggregate('Equipment nomenclature final','concatenate',expression:="COMPLETE TAG",filter:= ("Zone" is  attribute(  @atlas_feature , 'Zone' ) and  "Fluid  code" is attribute(  @atlas_feature , 'Fluid code' ) and  "PID" is attribute(  @atlas_feature , 'PID' )) ,concatenator:='; ')

And the result looks like this:

enter image description here

However the IDs aren't in a convenient order for readability on site and the aggregate function doesn't accept group_by parameters. I would like to have them grouped by 'Element Code', the first 2 or 3 letters of the ID (ex: EID, AV, AS, etc.) and in incremental numbers for the 3rd part of the ID. Ideally, the list would even return to next line when the Element code changes:

23 AS 011, 23 AS 012
23 AV 010, 23 AV 011
etc.

  • Have you looked at adding an attribute table to your atlas? There's an option to "only show features intersecting atlas feature" and you can filter based on an expression. – csk Jan 22 '18 at 17:53
  • Hello csk, thank you very much for your reply! I had already successfully played around with the attribute table for this case (using columns next to each other to generate a list) but the issue i have is that certain buildings have a lot of equipment and the attribute table system leaves too much empty space on the test sheet. This is why I reverted back to concatenate methods. – N.McFadden Jan 23 '18 at 6:37
3

Just by way of an update, you can now achieve some form of order within aggregate functions in QGIS 3.8 (see changelog entry here) by specifying the order_byparameter.

You can order by two fields by concatenating them in the order_by parameter. However the order will be alphabetical so if you are using integers make sure to pad with leading zeros so that e.g. 10 (=010) comes before 100.

For example I have trees within a road segment and I want to concatenate the tree IDs by genus and then trunk size.

I could use the following expression assuming the road segments is the atlas coverage layer:

aggregate('trees','concatenate',"tree_id",
within($geometry,geometry(@atlas_feature)),
order_by:="genus"||lpad("dbh",3,'0'))

And here is an example result (I have added the genus and dbh to "tree_id" above to just to show the actual data) (also if you are counting points I filtered out some of the data in the list...):

enter image description here

Without the order_by parameter it would look like this:

enter image description here

Your Answer

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 or ask your own question.