Select to view content in your preferred language

Arcade issue within dashboard

729
13
09-30-2025 05:55 AM
Labels (1)
MicBry
by
Emerging Contributor

Hi!

I have an issue connected to my dashboard and its widgets. I am currently using enterprise 11.3. In short, my dashboard uses a category selector and an indicator. The widgets have different data, but are connected through similar fields. 

My indicator uses a datapoint and a redference value. Both use the same data source, however they are filtered in different ways. My first value (datapoint) shows land (m2) that our municipal landlort taker care of. The seconf value shows land that the residents themselves takes care of. The third value is a grouping of the other to. In short:

Datapoint = Area m2

Reference value = other areas m2

Own value = Area + other areas m2 

 

So, to the issue. I have certain areas where the reference value is non existent, i.e. areas where no land is to be taken care of by the residents. This makes the arcade script fail behind the scenes. The indicator returns no data even when an area containt datapoint but not reference value.I would like the reference value to be treated as 0 so that i always get a result. 

 

Down below is a basic interpretation of my script:

var allmannaytor = $datapoint["sum_SHAPE.STArea()"]
var hyresgastskottaytor = $reference["sum_SHAPE.STArea()"]
var total = allmannaytor + hyresgastskottaytor

return {
  //textColor:'',
  //backgroundColor:'',
  topText: 'Allmänna ytor: ' + Text(Round(allmannaytor, 0), "#,###") + ' m²',
  topTextColor: '',
  topTextOutlineColor: '',
  topTextMaxSize: 'medium',
  middleText: 'Hyresgästskötta ytor:  ' + Text(Round(hyresgastskottaytor, 0), "#,###") + ' m²',
  middleTextColor: '',
  middleTextOutlineColor: '',
  middleTextMaxSize: 'medium',
  bottomText: 'Totala ytor: ' + Text(Round(total, 0), "#,###") + ' m²',
  bottomTextColor: '',
  bottomTextOutlineColor: '',
  bottomTextMaxSize: 'x-small',
  //iconName:'',
  //iconAlign:'left',
  //iconColor:'',
  //iconOutlineColor:'',
  //noValue:false,
  //attributes: {
    // attribute1: '',
    // attribute2: ''
  // }
}
 
I have tried to adjust this script adding if-statements, isempty and so on. Nothing is working for me. I need something that tells the dashboard to check for reference value first. If the value is non existing (not 0) it needs to be interpreted as 0. If a value exists this function can be ignored. 
 
Any suggestions? 
0 Kudos
13 Replies
MicBry
by
Emerging Contributor

Hi!

Thank you so much for reaching out. It didn't work but i appriciate you trying. 

Best, Michaela

0 Kudos
Neal_t_k
Frequent Contributor

@MicBry I am not sure this can be done in this manner.  I don't think the indicator even gets to the calculation part in the advanced editor, If either the datapoint or the reference can't be evaluated, the indicator defaults to 'No Data'.  I ran a couple tests, hard coded  a variable in place of the reference, and as soon as I filtered the data to something that the reference couldn't evaluate, the indicator went to no data, even though the advanced editor should have evaluated correctly.

0 Kudos
MicBry
by
Emerging Contributor

Hi again Neal!

That's my thought as well.. I've run so many test by now and it doesn't seem like it wants to accept any solution if the referencepoint can be seen as non existant. It's unfortionaty, but i'm happy to see that we both reached the same conclusion. Thanks again for taking the time to look further into this for me. Really appriciate it!

 

/Michaela

0 Kudos
Neal_t_k
Frequent Contributor

@MicBry Maybe a new data expression like this would be the direction to go.  It makes a new feature set with the original "sum" and then the new column is zeroed out if it meets the criteria, otherwise it is the sum.  You can then build the indicator in the same manner but using the expression as the source.

var portal = Portal('https://www.arcgis.com');
var feature_layer = FeatureSetByPortalItem(portal, 'XXXXXXXXXXXXXXXXXXXX', X, ['SumField', 'CriteriaField']);


var New_Features = [];


for (var f in feature_layer) {

    var SumField_Fix = When(
        f.CriteriaField == 'Criteria', 0,
         f.SumField
    );

    var New_Feature = {
        attributes: {
            CriteriaField: f.CriteriaField,
            SumField_New: SumField_Fix,
            SumField_Old: f.SumField
        }
    };
    

    Push(New_Features, New_Feature);
}

var out_dict = {
    fields: [
        { name: "CriteriaField", type: "esriFieldTypeString" },
        { name: "SumField_New", type: "esriFieldTypeInteger" },
        { name: "SumField_Old", type: "esriFieldTypeInteger" }
    ],
    geometryType: "",
    features: New_Features
};


return FeatureSet(Text(out_dict));

you would just have to make sure you include the proper fields for your filter/queries.

0 Kudos