3.4 Expression Examples

Copy-paste samples for Markdown { } expressions. Replace source and column names with your project layers. Test live in the Expression Syntax Helper.

Syntax reference: 3.3 Expression Syntax.

Filters and aggregations

Land-use area (single filter):

Commercial area (ha): {"Kallang - LU||LandUse".filter('LANDUSE','COMMERCIAL','==')."Area_Ha".sum:,.0f}

Chained filters:

Open space in sub-block: {"Kallang - LU||LandUse".filter('LANDUSE','OPEN SPACE','==').filter('ID_SUBBLOCK','KA.01','==')."Area_Sqm".sum:,.0f}

CSV list (no aggregation):

Types: {"Kallang - LU||LandUse"."Type"}

Join column values:

IDs: {"Kallang - LU||LandUse"."ID".join(' / ')}

Distinct values and count:

Zones: {"Parcels"."ZONE".unique}
Zone count: {"Parcels"."ZONE".uniquecount}

First / second row value:

First name: {"Sites"."name".n-0}
Second name: {"Sites"."name".n-1}

Lookup table

Replace codes with labels from a docs CSV source:

{"csvtable".filter('code','A1','==')."label".sum}

Context variable chain with lookup:

{$ids.split(', ').lookup("csvtable",'id','name').join(', ')}

Ratios and arithmetic

Share of total area:

Open space share (%): {"Kallang - LU||LandUse".filter('LANDUSE','OPEN SPACE','==')."Area_Ha".sum / "Kallang - LU||LandUse"."Area_Ha".sum * 100:,.1f}

Pure math (no data source):

{(10 + 2)/3}

Geometry metrics

Total polygon area in hectares:

Network area (ha): {"Kallang - Network||Service"."geomarea".sum / 10000:,.2f}

Line length total:

Total length (m): {"Streets||Centerline"."geomlength".sum:,.0f}

Comparisons (true / false icons)

{10 > 5}
{"Kallang - LU||LandUse".filter('LANDUSE','OPEN SPACE','==')."Area_Ha".sum > 5}

GG gross floor area (GFA)

Total GFA (m²) from extruded building layer — helper column gg_gfa|Layer Name:

Total GFA (m²): {"Parcels||Building"."gg_gfa|Kallang Building".getitem('').getindex(1).sum:,.0f}

Sum floor counts across space types:

Total floors: {"Parcels||Building"."gg_gfa|Kallang Building".getitem('').getindex(0).sum}

Residential GFA only (JSON key = space type):

Residential GFA: {"Parcels||Building"."gg_gfa|Kallang Building".getitem('resi').getindex(1).sum:,.0f}

Context variables only

Parcel {$idParcel} — page {$page}

Keywords

examples, expression, filter, sum, avg, join, lookup, geomarea, geomlength, gg_gfa, ratio, percentage, unique, markdown, samples