Select to view content in your preferred language

Use a range for selector in Dashboard

115
0
2 weeks ago
MeleKoneya1
Regular Contributor

Hello

I am trying to filter data in a dashboard by ranges in the layer.    I can calculate a new field, but would rather not have to do this as new data will be added soon

I have some building data and need to group the records by ranges of leased percentages

  • 0-5%
  • 5-10%
  • 10-15
  • 15-20%
  • 20-25%
  • 25-30%
  • 30-50%
  • 50-100%

I have created a feature set that assigns the ranges, but I can't figure out how to configure a selector to filter the layer on the dashboard map

 
var fs = FeatureSetByPortalItem(
  Portal(''),
  // portal item id
  "",
  0, // layer id
  ["Record_ID", "Percent_Leased" ], // fields to include
  true // include or exclude geometry
);

// convert field list to series of SQL expressions for Distinct function
var fields = Schema(fs)['fields']
var sqlfields = []

for (var f in fields) {
  Push(
    sqlfields,
    {name: fields[f]['name'], expression: fields[f]['name']}
  )
}

var leasecat_sql = `CASE
WHEN Percent_Leased >= 0 and Percent_Leased < 5 THEN '0-5'
WHEN Percent_Leased > 5 and Percent_Leased <= 10 THEN '5-10'
WHEN Percent_Leased > 10 and Percent_Leased <= 15 THEN '10-15'
WHEN Percent_Leased > 15 and Percent_Leased <= 20 THEN '15-20'
WHEN Percent_Leased > 20 and Percent_Leased <= 25 THEN '20-25'
WHEN Percent_Leased > 25 and Percent_Leased <= 30 THEN '25-30'
WHEN Percent_Leased > 30 and Percent_Leased <= 50 THEN '30-50'
WHEN Percent_Leased > 50 THEN '50-100'
ELSE 'UNK'
END`

return Distinct(
  fs,
  Splice(
    sqlfields,
    {name: 'Lease_category', expression: leasecat_sql}  )
)

Any thoughts on how to use the Lease_Category in the Featureset as an action to filter the layer by Percent_Leased?    Thank you 

0 Kudos
0 Replies