I am trying to return a sum value of filtered population counts from counties noted in my filter function. I am having issues getting it to display in an indicator widget. See anything I am doing wrong with my code:
var filtered_pop = Filter($datapoint.sum_SUM_Population,
'Name == "Shelby County" || Name == "Tipton County" || Name == "Lauderdale County" || Name == "Dyer County" || Name == "Lake County" || Name == "Obion County" || Name == "Weakley County" || Name == "Gibson County" || Name == "Crockett County" || Name == "Haywood County" || Name == "Fayette County"')
return {
//textColor:'',
//backgroundColor:'',
topText: 'Total Population',
//topTextColor: '',
//topTextOutlineColor: '',
topTextMaxSize: 'medium',
middleText: filtered_pop,
middleTextColor: '',
middleTextOutlineColor: '',
middleTextMaxSize: 'large',
bottomText: '(counties experiencing at least very strong shaking)',
//bottomTextColor: '',
//bottomTextOutlineColor: '',
//bottomTextMaxSize: 'medium',
//iconName:'',
//iconAlign:'left',
//iconColor:'',
//iconOutlineColor:'',
//noValue:false,
//attributes: {
// attribute1: '',
// attribute2: ''
// }
}
Solved! Go to Solution.
This has a few problem. SQL is picky about quotes, so you'll have to encase the entire thing in double quotes and use single quotes for each item. You have to use a single = sign. And you have to use "or" not "||"
var filtered_pop = Filter($datapoint.sum_SUM_Population,
"Name = 'Shelby County' or Name = 'Tipton County' or ..."
However, by using "in", you can make this much easier to read and much shorter.
var filtered_pop = Filter($datapoint.sum_SUM_Population,
"Name in ('Shelby County', 'Tipton County', ...)"
This has a few problem. SQL is picky about quotes, so you'll have to encase the entire thing in double quotes and use single quotes for each item. You have to use a single = sign. And you have to use "or" not "||"
var filtered_pop = Filter($datapoint.sum_SUM_Population,
"Name = 'Shelby County' or Name = 'Tipton County' or ..."
However, by using "in", you can make this much easier to read and much shorter.
var filtered_pop = Filter($datapoint.sum_SUM_Population,
"Name in ('Shelby County', 'Tipton County', ...)"