Work out dwellings per hectare, a zone's share of total site area, or a yes/no flag for parcels that meet a minimum lot size, right in the layer. A formula column calculates its value for each row from other columns, and updates when they change.
Add a formula column
In the Table view, click Add column.
Choose Formula.
Type a Name.
Type the formula, like
[population] / [perimeter_m]. gGIS shows the result for the first row as First feature, or an error if the formula isn't valid.Click Add column.
A formula column is read-only. Its header shows an ƒx badge. Click the badge, or right-click the header and choose Edit column, to see or edit the formula. Click Save column to keep your change.
Formula syntax
Refer to a column by putting its name in square brackets, like
[lot_area].Math operators:
+ - * / % ^.Comparisons:
= != < <= > >=.Logic:
and,or,not.Join text with
&. Put text in quotes, like"R1".
A blank input, or dividing by zero, gives a blank result. Wrap a value in coalesce(…, 0) to get zero instead. A formula can't refer to its own column.
Functions
Math:
min,max,sum,abs,floor,ceil,sqrt,round(x, decimals),number.Logic:
if,coalesce,isblank.Text:
len,lower,upper,trim,concat,contains.
The formula editor lists your columns under Available columns, functions under Functions & operators, and whole-layer functions under Percentages & totals.
Totals and percentages across the layer
These functions look at every row in the layer, even rows hidden by a filter. Add an optional group column to calculate within each group.
total(value, group): the sum of a value.avg(value, group): the average of a value.count(group): the number of rows.countif(test, group): the number of rows that pass a test.share(value, group): this row's share of the total, from 0 to 100.pctif(test, group): the percentage of rows that pass a test.
For example, share([parcel_area], [zone_code]) gives each parcel's share of the total area in its zone.
Write a formula from a description
In the formula editor, describe what you want in plain words, like "dwellings per hectare." gGIS suggests a formula. Type in Refine it… to adjust it, then click Use this. gGIS fills in the formula, and the name if it's empty. Click Add column to finish.
The formula assistant needs an Anthropic API key saved as a credential. gGIS uses the first credential whose name contains "Anthropic" or "Claude." Without one, the formula assistant doesn't appear in the formula editor.
Save your Anthropic API key as a credential, and name it so it includes "Anthropic" or "Claude." To give your team access, share the credential with them.
Keep formulas when you export
When you export a layer with formula columns, open the arrow next to Export to layer. Under Calculated columns, choose Keep formulas to keep columns calculating, or Values only to turn them into fixed numbers.