Mergin Maps

Support tip - using conditions to improve your Mergin Maps survey

Using conditional expressions in your survey project can be a great way to increase the accuracy of your field data collection. Using QGIS expressions can be a powerful tool for improving the usability of your survey in the field. Due to the flexibility of QGIS, there are many ways that this tool can be used, but we will show a couple of examples to get you started. 

Example 1 - Restricting fields with expressions

Sometimes complex survey forms can become cluttered or confusing for surveyors who are recording data on smaller device screens. One way to make your forms more straightforward is to use expressions to only show fields that the surveyor needs to access. 

For example, you may be conducting a property survey that requires specific fields to be filled in depending on the type of property. Making the user have to scroll through each section of the form until they find the necessary fields can be confusing and time consuming for surveyors. Instead, you can use conditional expressions to only display fields that are required depending on the type of property being surveyed. 

Let’s start with a simple example project for our property survey. We have a background map and a point layer called ‘survey’  to record the information for each property. The table for the ‘survey’ layer is as follows:

Table 1
FieldTypeDescription
fidINTprimary_key
uuidtextUnique ID
surveyortextField to record surveyor username
survey_team
textRecord the survey team assigned to the property
createddate/timeTimestamp for when the record was created
last_updatedate/timeTimestamp for the last time the feature was updated
street_noINTStreet number
street_nametextStreet name
postal_codetextPostal code
floorsINTNumber of floors
typetextType of property (business or residential)
bus_nametextName of business
bus_typetextType of business
res_typetextType of house (bungalow, terraced, cottage, etc)
res_parkingtextType of parking available at the house (street, drive, garage)
res_occupeidBooleanIs the residence occupied?
Made with HTML Tables
Table 1
Field Type Description
fid INT primary_key
uuid text Unique ID
surveyor text Field to record surveyor username
survey_team
text Record the survey team assigned to the property
created date/time Timestamp for when the record was created
last_update date/time Timestamp for the last time the feature was updated
street_no INT Street number
street_name text Street name
postal_code text Postal code
floors INT Number of floors
type text Type of property (business or residential)
bus_name text Name of business
bus_type text Type of business
res_type text Type of house (bungalow, terraced, cottage, etc)
res_parking text Type of parking available at the house (street, drive, garage)
res_occupeid Boolean Is the residence occupied?
Made with HTML Tables

One way we can make this form easier for the surveyor to use is to organise the fields into tabs using the Drag and Drop Designer. We can organise our survey into three tabs, Property, Business and Residential with a box for the surveyor information on the first tab:

Now that the fields are organised, we can take an extra step to make the form even more responsive to user inputs. We can use an expression to hide the Business and Residential tabs until the user chooses the type of property. To do this, select the tab and use the Control Visibility by Expression field to set an expression to show or hide the tab. 

For the Business tab use:

"Type" = 'business'

And for the Residential tab use:

"Type" = 'residential'

Now, when the user is entering data in the field, they will only see the Property tab until they select an option for the type field, it is also a good idea to set a ‘Not null’ constraint on the type field so that the user remembers to put in a value for the property or else they may not know that there is more information to collect!

*insert video*

Example 2 - Restricting edits with expressions

Now that we have our survey interface improved with some expressions, we can try a more advanced method to restrict who can edit features in our project. In our example, we only want surveyors to be able to edit entries created by or assigned to their survey team. 

We already have a field to record the surveyor’s username and their assigned survey team. We’ll compliment this with a nonspatial table that lists each surveyor’s username and their team, which looks like this:

Table 1
fid INT Primary Key
surveyor_id text UUID for surveyor record
username text Default value set to @mm_username to record the surveyors username
team text The surveyor’s assigned team, there are three teams in our example: red, blue and green
Made with HTML Tables

In our survey table, the surveyor field is set as non-editable and uses a default value expression of @mm_username, and the field is set to apply the default on update. 

Next we set up the survey_team field as a text widget with the following default value expression:

attribute(get_feature('surveyors','username',@mm_username), 'team')

In this expression, working from the inside out, we use the get_feature() function to retrieve the feature in the surveyors table which matches the username to the current user’s @mm_username. Then we use the attribute() function to return the value of the team field for that feature. This default value is only applied once when the feature is created. We disable editing for this field, or you can use an expression to only allow an admin user to edit the feature with an expression like (replace the text in parentheses with usernames of admin users):

@mm_username IN ('list', 'of', 'admin', 'usernames')

In this example, we also add a boolean field to the survey layer called can_edit, we’ll configure this field with an expression constraint that will prevent users from saving changes to a feature if they are not part of the survey team that created or is assigned to the feature.

First, we will set the default value of the can_edit field with the following expression:

attribute(get_feature('surveyors', 'username', @mm_username),'team') ILIKE "survey_team"

OR 

@mm_username IN ('replace this with','admin','users')

The expression above uses the same function used for the default value in the survey_team to retrieve the current user’s team association and checks that it matches the value of the survey team that is assigned to the feature. The statement after the OR operator checks if the user is an admin user. If the current user is an admin or member of the team associated with the feature, the value of the field will be set to true, if they are not in either of those groups it will be false. Make sure the default value is set to be applied on update.

Next, we will create an expression-based constraint so that the feature can only be saved if the value of the can_edit field is true:

"can_edit" = true

Finally, make sure to disable editing on the field. Your settings should look similar to this:

Now we can see in our example, this user who is on the red survey team, can only edit features assigned to that team:

*insert video 2*

Many more uses of conditional settings

These are just a few examples of ways you can use conditions in your project to improve the workflow and ensure data quality. The uses of conditions open your project to more customisation such as conditional symbology, time constraints, auto-filling fields based on certain values, and much more. Using the full power of QGIS will help you get the most out of your Mergin Maps project!

You might also like

Mergin Maps

The ecologist’s guide to offline GIS data collection and mobile mapping

March 6, 2026

Mergin Maps

Support tip - enhance your QGIS project with rule-based symbology

February 12, 2026

plugin

Plugin and API update brings simultaneous syncs

January 29, 2026

QGIS

How to Import Geotagged Photos into QGIS for Fieldwork Mapping

January 23, 2026

Mergin Maps

Share maps via URL: now in early access

December 15, 2025

QGIS

How to collect GPS points for QGIS on Android with Mergin Maps

December 8, 2025

QGIS

How to use Mergin Maps to collaborate on QGIS projects

November 28, 2025

Mergin Maps

Support Tip: Using HTML to improve your Mergin Maps project

November 12, 2025

Mergin Maps

Photo sketching is now available in Mergin Maps

October 28, 2025

Mergin Maps

Best Practices for User Management in Mergin Maps

October 10, 2025

QGIS

Create professional survey reports using QGIS Print Layout after field data collection

September 15, 2025

QGIS

5 Essential QGIS Plugins for GIS Professionals

August 13, 2025

Mergin Maps

Mergin Maps gets sketchy

July 31, 2025

Mergin Maps

Single Sign-On (SSO) is now available for Enterprise plans

June 30, 2025

partners

Camptocamp becomes first official Mergin Maps reseller

June 6, 2025

Mergin Maps

New API tools give you more user management options!

May 30, 2025

Mergin Maps

How to Conduct a Field Survey Using QGIS and Mergin Maps: A Complete Step-by-Step Guide

April 16, 2025

plugin

Great Scott! Mergin Maps Plugin has a time machine

March 19, 2025

Mergin Maps

Unlocking premium features of Mergin Maps for all

January 15, 2025

Mergin Maps

2024 - Year in review

December 20, 2024

Mergin Maps

Support tip: What to do if your project is too big

November 29, 2024

Mergin Maps

Mergin Maps now measures in taps

October 24, 2024

Mergin Maps

Announcing the first ever book about Mergin Maps from Locate Press

September 20, 2024

mobile

Support tip - How to make recording lines and polygons simple

August 30, 2024

Mergin Maps

5 best field data collection apps

July 17, 2024

Mergin Maps

Introducing Editor permissions - our most-requested feature!

June 20, 2024

Mergin Maps

We hope you’re enjoying the new experience!

May 31, 2024

QGIS

Support tip: Add SVG symbols to your QGIS project

May 2, 2024

Mergin Maps

Mergin Maps app is getting a fresh new look

March 28, 2024

Mergin Maps

QField vs. Mergin Maps - App Comparison

March 1, 2024

Mergin Maps

Hello from Mergin Maps!

February 13, 2024

plugin

Support tip: Downloading a previous version of your project

January 31, 2024

Mergin Maps

Mergin Maps 2023: our year in review

December 28, 2023

mobile

Mergin Maps is now faster and more stable than ever

November 15, 2023

plugin

Download tiles for offline background maps in five steps

October 30, 2023

partners

We've partnered with MarXact for high-precision surveying in Mergin Maps

October 27, 2023

event

Come see us at INTERGEO 2023 in Berlin

September 29, 2023

Mergin Maps

Mergin Maps Gets a Brand Refresh

September 27, 2023

Mergin Maps

We’ve added the ability to customise photo names in Mergin Maps!

August 31, 2023

mobile

You asked for it and we delivered… Position tracking in Mergin Maps!

August 22, 2023

Mergin Maps

Features wishlist - Help us help you!

July 27, 2023

Mergin Maps

Check out the Mergin Maps interview on App of the Day

May 4, 2023

event

Mergin Maps hope to see you at GeoBusiness London 2023

May 2, 2023

Mergin Maps

Worried about using open-source geospatial software for your business? Mergin Maps support is here for you!

April 28, 2023

Mergin Maps

Camptocamp partners with Mergin Maps to deliver open source GIS solutions

April 25, 2023

Mergin Maps

Subscription tiers are going to change

April 18, 2023

Mergin Maps

Mergin Maps Community and Enterprise Editions

March 31, 2023

Mergin Maps

Introducing Workspaces: Simplified Collaboration

January 31, 2023

Mergin Maps

Mergin Maps: a year in review (2022)

December 20, 2022

Mergin Maps

Mergin Maps in MapScaping podcast

December 15, 2022

plugin

View and track changes in QGIS

December 14, 2022

By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Cookie Policy for more information. Deny cookies here.