This article provides a few tips for when you are filtering based on the fields within a specific form:
- Field names
- Select fields
- Date fields
- Number fields
- Text fields
Field names
If a field name contains a space, the space needs to be replaced with an underscore when filtering.
Example:
A field name is “Household contents”. When filtering on this field, you would use the filter: Household_contents
Multiple choice fields
Responses to multiple choice fields are based on option value, not the label.
Example:
You have a 'Select One' field named “Chronic conditions” with the options “1. Yes [Y]” and “2. No [N]”. You want to see all the submissions containing chronic conditions. You would use the following filter: Chronic_conditions: Y
'Select Many' fields are referenced slightly different to 'Select One' fields. To filter on a 'Select Many' field type, you must prefix the field name with "mobmulti_".
Example:
You have a 'Select Many' field named “Household characteristics” with option values 1 to 4. To filter for all the submissions where options “1” and “3” were selected for this field, you would use the following filter: mobmulti_Household_characteristics:1 AND mobmulti_Household_characteristics: 3
Date fields
To reference a date field type in a filter, you must prefix the field name with "mobdate_". Dates are specified in the format YYYY-MM-DDT00:00:00Z.
The basic syntax supports addition, subtraction and rounding at various levels. Commands can be chained together and are evaluated from left to right. '+' and '-' denote addition and subtraction, while '/' denotes "round". Round requires only a unit, while addition and subtraction require an integer value and a unit. Command strings must not include any spaces.
Modifier | Result |
---|---|
/h | Round to the start of the current hour |
/d | Round to the start of the current day |
+2y | Exactly two years in the future from now |
-25m | Exactly 25 minutes ago |
-1d | Exactly 1 day ago |
/d+6M+3d | 6 months and 3 days in the future from the start of the current day |
+6M+3d/d | 6 months and 3 days in the future from now, rounded down to nearest day |
Example:
You have a field named "DOB". To retrieve all submissions where the date of birth reported was between 9 June 2010 and 1 year from the current date, you would use the filter: mobdate_DOB: [2010-06-09T00:00:00Z TO now -1y]
Number fields
To reference a numeric integer field type in a filter, you must add "mobint_" to the field name.
Example:
You have a field named "Household Member Count". To display all submissions where households had 4 or more members, you would use the filter: mobint_Household_Member_Count: [4 TO *]
To reference a numeric decimal field type in a filter, you must add "mobdouble_" to the field name.
Example:
You have a field named "Baby Birth Weight". To filter for all submissions reporting birth weights under 2.5kg, you would use the filter: mobdouble_Baby_Birth_Weight: [0 TO 2.5]
Text fields
To reference a text field type, you can simply use the field name.
Example:
You have a field named "Job Other". To view all submissions where the job description entered was "Dentist", you would use the filter: Job_Other: “Dentist”
You can also make use of "wildcards" to filter for partial matches. To perform a single character wildcard match, use the "?" character. To perform a multiple character wildcard match, use the '*" character. Do not enclose the search term in quotations.
Examples:
The filter Job_Other: Art* will return results containing both “Artist” and “Artisan”
The filter Job_Other: T?ster will return results containing both “Tester” and “Taster”