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:
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