In this article
How to use filter identifiers to display selected options in a widget. A sample code with available properties is given.
By giving a filter an identifier (a name), you can use the selected filter value as the filter option in a widget. For instance, you can use it in a column to calculate the metric for the current reporting period and show if the value has changed from the previous reporting period.
Available properties:
@filterIdentifier.selectedOption.label - the label given to the currently selected option.
@filterIdentifier.selectedOption.value - the value of the currently selected option.
@filterIdentifier.selectedOption.previous - The "previous property" you're referring to is likely a calculated property that uses a data expression to determine its value based on data from the previous reporting period. This type of property can be useful when you want to compare the current data to data from the previous period to see how things have changed.
layoutArea toolbar {
filter singleselect filterIdentifier {
value: InYear(survey:interview_start, -1, 0)
previous: InYear(survey:interview_start, -2, -1)
}
option radio o2 {
label: "Rolling Quarter"
value: InQuarter(survey:interview_start, -1, 0)
previous: InQuarter(survey:interview_start, -2, -1)
}
option radio o3 {
label: "Rolling Month"
value: InMonth(survey:interview_start, -1, 0)
previous: InMonth(survey:interview_start, -2, -1)
}
}
Filters.md 9/11/2019
5 / 6
label: "Reporting period"
global: false // if selected filter should be applied globally
option radio o1 {
selected: true // option selected by default
label: "Rolling Year"
value: InYear(survey:interview_start, -1, 0)
previous: InYear(survey:interview_start, -2, -1)
}
option radio o2 {
label: "Rolling Quarter"
value: InQuarter(survey:interview_start, -1, 0)
previous: InQuarter(survey:interview_start, -2, -1)
}
option radio o3 {
label: "Rolling Month"
value: InMonth(survey:interview_start, -1, 0)
previous: InMonth(survey:interview_start, -2, -1)
}
page "Filter summary"
// see what's selected
widget title {
layout column {
tile value {
value: @filterIdentifier.selectedOption.label
}
}
}
widget accountList{
label: @filterIdentifier.selectedOption.label
size: large
table: accounts:
sortColumn: accountName
sortOrder: ascending
navigateTo: "Account"
hierarchy: accounts:ParentAccountID
view metricWithChange metrics {
backgroundColorFormatter: backgroundColor
valueColorFormatter: valueColor
fontSize:medium
roundCorners:true
}
column value accountName {
value: accounts:AccountName
}
column metric LTR {
label: "LTR"
value: average(score(survey:Q1), @filterIdentifier.selectedOption.value)
Filters.md 9/11/2019
6 / 6
previous: average(score(survey:Q1),
@filterIdentifier.selectedOption.previous)
target: 9
format: formatterLTR
align: center
view: metrics
}
}