In this article
Create custom filters with "filterType" and "optionType" properties for single/multi-select or hierarchical filters, with personalization and restrictions.
If you desire to establish special filter categories based on values from a question, you can construct your own filter.
Basic custom filter properties
filter filterType [identifier] {
// where filterType ::= singleselect | multiselect | hierarchy
// identifier is optional. If you want to refer to the filter value
// it must have a unique identifier label: "Filter label"
option optionType [optionIdentifier] {
// where optionType ::= checkbox | radio, depending on filterType
label: "Option 1" // optionIdentifier is optional
value: condition // e.g. survey:q1 > 7
}
...
}Singleselect example
layoutArea toolbar {
filter singleselect period {
label: "Reporting period"
option radio s1 {
label: "Last quarter"
value: InQuarter(survey:interview_start, -1, 0)
}
option radio s2 {
label: "Last 6 months"
value: InMonth(survey:interview_start, -6, 0)
}
option radio s3 {
label: "Last 11 months"
value: InMonth(survey:interview_start, -11, 0)
}
option radio s4 {
label: "Last 12 months"
value: InYear(survey:interview_start, -1, 0)
}
}
}Multiselect example
layoutArea toolbar {
filter multiselect {
label: "Account Rating"
option checkbox {
label: "Gold"
value: accounts:TotalAccountValue > 200000
}
option checkbox {
label: "Silver"
value: accounts:TotalAccountValue >99999 AND accounts:TotalAccountValue
<199999
}
option checkbox {
label: "Bronze"
value: accounts:TotalAccountValue < 100000
}
}
}Hierarchy filter example
config hub {
hub: 1169
table hier = dbdesigner.364 // table id
table survey = p1079889.response
// the relationship between hierarchy and survey must be defined
// as between any other two tables
relation oneToMany rel4 {
primaryKey: hier:id
foreignKey: survey:q1
}
}
layoutArea toolbar {
filter hierarchy {
label: "Hierarchy filter label"
hierarchy: hier:174 // hierarchy id
optionLabel: hier:language_text
root: 45
default: 45
}
}You can specify a default selection for a hierarchy filter by using the "default" property and referencing the id of the desired hierarchy node.
You can also restrict filtering to only a part of the hierarchy, such as a specific country, by utilizing the "root" property. This will conceal the rest of the hierarchy, allowing the user to only set a filter from that node and downwards in the hierarchy.
These properties can also be dynamically obtained from a hub table, such as Node Assignments from Hierarchy Management, to offer personalized filter capabilities. For example, when reporting on employee data in a contact database.
config hub {
hub: 129227
table hierarchy = dbdesigner.19423
table userNodes = Hierarchy11148.NodeAssignments
table employees = p1867705701.response
relation oneToMany {
primaryKey: hierarchy:id
foreignKey: employees:hierarchy
}
userProperty claim nodeId {
joinKey: userNodes:UserName
value: userNodes:NodeId
}
}
layoutArea toolbar {
filter hierarchy {
label: "Hierarchy"
hierarchy: hierarchy:19423
optionLabel: hierarchy:language_text
default: @currentUser.nodeId
root: @currentUser.nodeId
}
}Similar to any other applied filters, Custom filters will appear in the filter summary.
For details of the properties and settings, refer to filter in the CDL Reference Guide.