Documentation & Knowledge Base

Documentation & Help

Find instructions, guides, and answers to your questions regarding the use of the Gismatrix platform.

Dropdown Lists (Lookups)

The Dropdown Lists (lookups) tool (often referred to in database terminology as Lookups, Value Lists, or Joins) allows you to transform any standard text or numeric field in a vector layer's attribute table into an intuitive dropdown selection menu. Instead of typing values manually—which is prone to typos—users select a validated option from a predefined list.

💡 Why and when to use dropdown lists?

  • Prevent errors & ensure standardization: Users cannot enter inconsistent variations like "NY", "New York", or "newyork"—they always pick a standardized value from the list.
  • User-friendly interface (separating key and description): A compact code or numeric ID can be physically stored in the database (e.g., 126), while the user sees a meaningful description in both the edit form and the Info window (e.g., 126 - Main Arterial Road).
  • Cascading (dependent) menus: The options inside a dropdown can dynamically filter based on a selection made in another field on the same form (e.g., selecting a State restricts the available Cities).

1. Basic Configuration

In the main window, click the + (Add) button to create a lookup rule for a column in your current layer. For each row, configure:

  • ✔
    Column name (local column – t1k1): The field in the current layer you are configuring. When a user selects an item from the dropdown menu, the item's key value is physically saved into this column. Each column name is displayed next to an icon representing its database data type.
  • ✔
    Mode: Determines how lookup options are retrieved. Choose between Simple (quick graphical table link without writing code) and Advanced (SQL) (custom SQLite SELECT query).
  • ✔
    Settings Button (... on phones): Opens the detailed configuration dialog for the selected mode (Simple or Advanced). You must select a Column name first before opening Settings.
⚠️ Data Type Compatibility Rule: The data type of the lookup's Key column must be compatible with your local column (t1k1). For example, if your local column is numeric (Integer or Numeric), you cannot map a text (Varchar / Text) key column to it. However, the display value column can be of any type (typically text).
🔒 Geometry & Binary Restriction: Geometry columns (Geom) and binary data columns (BLOB / Bytea) are automatically excluded for safety and structural integrity and cannot be used as lookup keys or display values.

2. Simple Mode

Simple mode is designed for quickly linking your layer column to another table (dictionary/lookup table) open in your workspace without writing any SQL code.

UI Setting Detailed Description and Behavior
Target table (t2) Select the database table from which the dropdown options will be populated.
Target key column (t2k1) Select the column in the target table whose value will be physically saved into your local column upon selection (usually a code or ID). Note: Only columns with data types compatible with your local column are listed.
Target value column (t2v1) Select the column in the target table that contains the user-friendly descriptive text shown on the screen (e.g., species name, municipality name, status description).

3. Advanced Mode (SQL)

Advanced mode gives administrators complete flexibility using any custom SQLite SELECT statement. Use this mode when you need custom filtering (WHERE), custom sorting (ORDER BY), combining multiple columns into a single label (using the || operator), joining multiple tables, or filtering cascading dropdowns.

Example of an Advanced SQL Statement

SELECT code_id AS myCode, description AS myDesc FROM lookup_table WHERE active = 1 ORDER BY description ASC

As you type your SQL query, Gismatrix automatically parses the SELECT columns and populates the two mapping dropdowns below the editor:

  • Key column (from SQL) (t2k1): Select or type the column name or AS alias from your SQL statement that represents the key to be stored in the database (in the example above: myCode).
  • Display value column (from SQL) (t2v1): Select or type the column name or AS alias that represents the display text shown to the user (in the example above: myDesc).
🛠 SQL Toolbar & Verify Button: The toolbar above the SQL editor provides quick-insert helpers for Tables, Columns, Operators, Aggregates, and Functions, along with a Beautify button to format your SQL. Clicking the Verify button (checkmark icon) dry-runs your query, validates column data types against your local column, and displays the total row count along with a live sample of the first 5 formatted items.
📝 Unquoted Identifiers in SQLite: Write table and column names in your SQL queries without double quotes (e.g., SELECT code_id, name FROM municipalities rather than "code_id"). Only use quotes if an identifier contains spaces or special characters. Always wrap text literals in WHERE clauses in single quotes (e.g., WHERE status = 'active').

4. Display Mode and Column Join Separator

Regardless of whether you use Simple or Advanced (SQL) mode, the Display mode setting controls how each option is formatted inside the dropdown menu and the Info window:

Value only

Displays only the descriptive text from the value column (hides the key).

New York

Key and value

Displays both the key and the value connected by the separator, with the key first.

100-New York

Value and key

Displays both the value and the key in reverse order, connected by the separator.

New York-100

Column join separator (Separator)

The Column join separator field is visible when either Key and value or Value and key is selected (the default character is -).

Important – No automatic spaces: Gismatrix uses the separator string literally as entered and does not automatically pad it with spaces:

  • If you enter - (no spaces), the output is: 100-New York
  • If you enter - (space, hyphen, space), the output is: 100 - New York
  • If you enter | , the output is: 100 | New York

5. Cascading Dropdowns (Filters) & Dynamic SQL Placeholders

Cascading dropdowns allow the options of one field (e.g., City or Cadastral Municipality) to dynamically refresh and filter based on the value currently selected in another field of the same layer (e.g., State or Municipality). Up to two parent columns can be linked:

  • In Advanced (SQL) mode, these fields are labeled Dependent column 1 ({$1}) and Dependent column 2 ({$2}) (internal properties fk1 and fk2).
  • In Simple mode, under Filters (main table links), they are labeled Foreign key 1 (Optional) and Foreign key 2 (Optional).
How Cascading Filtering Works:

Selecting a local column in fk1 (or fk2) instructs the form to automatically reload the child dropdown whenever the user changes the parent field. However, to filter the query results with a WHERE clause, you must configure the child lookup in Advanced (SQL) mode and include the corresponding dynamic placeholder ({$1}, {%1}, or {#1}) in your SQL query. If a required parent field is empty, the child dropdown remains disabled/empty until the parent value is selected.

Dynamic SQL Placeholders by Parent Data Type

Before executing your SQL query, Gismatrix injects the live value of fk1 (index 1 or shorthand without number) and fk2 (index 2) into the placeholders below. Choose the placeholder that matches the data type of the referenced parent column:

🔤 Text (String)

Used when the parent column contains text (Varchar / Text). Must be wrapped in single quotes in your SQL query!

  • {$1} or {$} → from fk1
  • {$2} → from fk2

Example: WHERE state_code = '{$1}'

🔢 Integer

Used when the parent column is a whole number (Integer, Smallint). Converts value to integer. Do NOT wrap in quotes!

  • {%1} or {%} → from fk1
  • {%2} → from fk2

Example: WHERE county_id = {%1}

🔣 Decimal (Float)

Used when the parent column is a decimal number (Numeric, Double, Single). Preserves decimals. Do NOT wrap in quotes!

  • {#1} or {#} → from fk1
  • {#2} → from fk2

Example: WHERE rate = {#1}

Step-by-step Examples: Setting up a Cascading Dropdown

  1. Suppose your layer has a parent column (e.g., state_code) and a child column (e.g., city_id).
  2. Add a lookup row for city_id, set the Mode to Advanced (SQL), and click Settings.
  3. Under Dependent column 1 ({$1}), select the parent column state_code.
  4. Enter the SQL query in the editor and select your Key column (from SQL) and Display value column (from SQL):

1. If the parent column is TEXT ({$1}):

SELECT city_code, city_name FROM cities WHERE state_fk = '{$1}' ORDER BY city_name ASC

2. If the parent column is an INTEGER ({%1}) combined with a second TEXT filter ({$2}):

SELECT occupancy_id, occupancy_desc FROM occupancy_types WHERE category_id = {%1} AND zone_type = '{$2}' ORDER BY occupancy_id ASC
💡 Pro Tip for substring searches (LIKE):

When using a LIKE operator with text parameters, place the placeholder directly inside the wildcard percent signs: WHERE city_name LIKE '%{$1}%'.

6. 🤖 AI Assistant Prompt Template (Get Help from AI)

Need help writing a custom SQL query or configuring a cascading dropdown for your specific tables? Copy the prompt template below, fill in your table and column names at the bottom, and paste it into any AI assistant (such as ChatGPT, Google Gemini, or Claude):

Copy and paste this prompt into an AI tool:

Help me configure a Dropdown List (Lookup / Join) in the Gismatrix GIS application.
Gismatrix technical rules:
1. The underlying database is SQLite. Table and column names in SQL queries should be written WITHOUT double quotes (e.g., SELECT id, name FROM my_table).
2. In the main window, I select the local "Column name" (t1k1) on my active layer and choose a Mode ("Simple" or "Advanced (SQL)").
3. The data type of the lookup key column (t2k1) must be compatible with the local column (t1k1). Geometry (Geom) and binary (BLOB) columns are not allowed.
4. In "Advanced (SQL)" mode, I write a SELECT query and specify:
   - "Key column (from SQL)" (t2k1): the column name or AS alias whose value is saved into t1k1.
   - "Display value column (from SQL)" (t2v1): the column name or AS alias displayed to the user.
5. "Display mode" has 3 options: "Value only", "Key and value", and "Value and key".
6. "Column join separator" is used literally without automatic spaces (to get spaces around a hyphen, I must enter " - ").
7. For cascading (dependent) dropdowns, I select a parent column from the current layer under "Dependent column 1 ({$1})" (fk1) or "Dependent column 2 ({$2})" (fk2) and filter my SQL WHERE clause using placeholders matching the parent column's data type:
   - Text (Varchar/Text): '{$1}' for fk1, '{$2}' for fk2 (must be wrapped in single quotes).
   - Integer: {%1} for fk1, {%2} for fk2 (no quotes).
   - Decimal (Float/Numeric): {#1} for fk1, {#2} for fk2 (no quotes).

My scenario for which I need the exact Gismatrix settings and SQL query:
- Current layer name, local column (t1k1), and its data type: [ENTER HERE, e.g., layer parcels, column mun_id, type Integer]
- Lookup table name and its columns: [ENTER HERE, e.g., table municipalities with columns id (Integer) and name (Text)]
- Desired display format (description only, or code + description): [ENTER HERE, e.g., 126 - Maribor]
- Does it depend on another column on the current layer (fk1/fk2): [ENTER HERE, e.g., no / or yes, depends on region_id (Integer)]