Select to view content in your preferred language

Indicator Expressions

978
3
Jump to solution
08-25-2022 07:03 PM
Labels (1)
JonathanMcD
Frequent Contributor

Apologies for the question, despite using AGOL for years I've never had the chance to sit down and learn Arcade.

I've an indicator that shows a value that can range between 0 and 5 based upon a single value held in the dataset. I'm wishing to include a small text description in the bottomText based upon the value returned.

Is this possible in an indicator?

Basically;

if a value is >0 but <1 , returns "a",

if a value is >=1 but <2 , returns "b" etc

 

In the indicator, if I add bottomText: Sdatapoint ["value"] >0 <1, 

a value of True is returned, which is fine....but my lack of knowledge prohibits me from taking this further.

Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Yes, you can do this. First in the indicator tab, click the Enable button in the Advanced Formatting section.

2022-08-26_9-37-07.png

Next, make these changes to the Expression. You'll be adding the code and uncommenting the bottomText properties.

var value = $datapoint["value"];
var bText = When(value == 0, "z",
      value < 1, "a",
      value < 2, "b",
      value < 3, "c",
      value < 4, "d",
      value <= 5, "e",
      "n/a")
return {
    //textColor:'',
    //backgroundColor:'',
    //topText: '',
    //topTextColor: '',
    //topTextOutlineColor: '',
    //topTextMaxSize: 'medium',
    middleText: $datapoint["count_OBJECTID"],
    middleTextColor: '',
    middleTextOutlineColor: '',
    middleTextMaxSize: 'large',
    bottomText: bText,
    bottomTextColor: '',
    bottomTextOutlineColor: '',
    bottomTextMaxSize: 'medium',
    //iconName:'',
    //iconAlign:'left',
    //iconColor:'',
    //iconOutlineColor:'',
    //noValue:false,
    //attributes: {
      // attribute1: '',
      // attribute2: ''
    // }
  }

 

View solution in original post

3 Replies
KenBuja
MVP Esteemed Contributor

Yes, you can do this. First in the indicator tab, click the Enable button in the Advanced Formatting section.

2022-08-26_9-37-07.png

Next, make these changes to the Expression. You'll be adding the code and uncommenting the bottomText properties.

var value = $datapoint["value"];
var bText = When(value == 0, "z",
      value < 1, "a",
      value < 2, "b",
      value < 3, "c",
      value < 4, "d",
      value <= 5, "e",
      "n/a")
return {
    //textColor:'',
    //backgroundColor:'',
    //topText: '',
    //topTextColor: '',
    //topTextOutlineColor: '',
    //topTextMaxSize: 'medium',
    middleText: $datapoint["count_OBJECTID"],
    middleTextColor: '',
    middleTextOutlineColor: '',
    middleTextMaxSize: 'large',
    bottomText: bText,
    bottomTextColor: '',
    bottomTextOutlineColor: '',
    bottomTextMaxSize: 'medium',
    //iconName:'',
    //iconAlign:'left',
    //iconColor:'',
    //iconOutlineColor:'',
    //noValue:false,
    //attributes: {
      // attribute1: '',
      // attribute2: ''
    // }
  }

 

JonathanMcD
Frequent Contributor

@KenBuja 

This is absolutely perfect, thank you. This is really helpful.

One final question;

Using Arcade doesn't allow me to then dictate the values and decimal places. Is it possible to set places to 2 using, somewhere, the round function?

0 Kudos
JonathanMcD
Frequent Contributor

Just replying to myself that just a little help is sometimes enough to push someone in the right direction.

I answered my own question with;

middleText: round ($datapoint["avg_Score__Overall_mean"],2)