Find Sum of Existing Indicators within Dashboard using an Arcade Data Expression

1513
4
Jump to solution
05-19-2023 07:10 AM
M_M
by
New Contributor III

Is it possible to create an indicator or list that sums up the values from existing indicators within the dashboard? I have been trying with arcade in a data expression but am not having any luck. For instance, my dashboard contains Indicator1, Indicator2, and Indicator3. I would like to find the sum of Indicators 1,2 and 3 and display the results in a new indicator (Indicator4) or in a new list etc. 

I have a fair amount of indicators on different tabs within the dashboard and each has a somewhat long filter applied, so I’m hoping to make it easy by referencing the existing indicators to find the sum. The indicators are all referencing the same data source and I’m in ArcGIS Online  

Thank you!

Melissa

1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Not directly, no.

 

What you could do: Instead of referencing a layer/expression and doing the filtering and grouping in the Indicator widgets, you could create an expression that returns a featureset with two fields: an indicator id and the corresponding value. Then, each Indicator widget would only have to filter for its id and display the value.

Something like this:

var fs = FeaturesetByPortalItem(...)

var out_fs = {
    geometryType: "",
    fields: [
    {name: "Indicator", type: "esriFieldTypeString"},
    {name: "Value", type: "esriFieldTypeDouble"},
    ],
    features: []
}

// Indicator 1:
var v = Count(Filter(fs, "Field = 123"))
Push(out_fs.features, {attributes: {Indicator: "count of 123", Value: v}})

// Indicator 2:
var v = Count(Filter(fs, "Field = 345"))
Push(out_fs.features, {attributes: {Indicator: "count of 345", Value: v}})

// ...

return Featureset(Text(out_fs))

 

And for the final Indicator, you could just use the SUM of the Value field.

 

 

Of course, that would require you to edit all the other Indicator widgets, so it might be easier to just redo the filter for the final Indicator...


Have a great day!
Johannes

View solution in original post

4 Replies
JohannesLindner
MVP Frequent Contributor

Not directly, no.

 

What you could do: Instead of referencing a layer/expression and doing the filtering and grouping in the Indicator widgets, you could create an expression that returns a featureset with two fields: an indicator id and the corresponding value. Then, each Indicator widget would only have to filter for its id and display the value.

Something like this:

var fs = FeaturesetByPortalItem(...)

var out_fs = {
    geometryType: "",
    fields: [
    {name: "Indicator", type: "esriFieldTypeString"},
    {name: "Value", type: "esriFieldTypeDouble"},
    ],
    features: []
}

// Indicator 1:
var v = Count(Filter(fs, "Field = 123"))
Push(out_fs.features, {attributes: {Indicator: "count of 123", Value: v}})

// Indicator 2:
var v = Count(Filter(fs, "Field = 345"))
Push(out_fs.features, {attributes: {Indicator: "count of 345", Value: v}})

// ...

return Featureset(Text(out_fs))

 

And for the final Indicator, you could just use the SUM of the Value field.

 

 

Of course, that would require you to edit all the other Indicator widgets, so it might be easier to just redo the filter for the final Indicator...


Have a great day!
Johannes
M_M
by
New Contributor III

@JohannesLindner  Thank you!!! 

What do you think the best course of action would be in this situation if I wanted the final sum indicator(s) to be able to be filtered by two Category Selectors (year and district name)?  All of the individual indicators that are used to sum up into the final indicators, are also actioned to be filtered by the same two Category Selectors (year and district name). As I have it now, if the Category Selector(s) are applied to filter the individual indicators, the 'final sum' indicators are not being filtered which is confusing to the user.

 

Thanks again--I really appreciate the help!! 

0 Kudos
JohannesLindner
MVP Frequent Contributor

In that case, I believe you're stuck with creating the filter in the widget.


Have a great day!
Johannes
0 Kudos
ttn0003
New Contributor

Hi @JohannesLindner 

I have been trying to create a sum indicator based on your suggestions, and I want to populate this sum value corresponding to map extent. But the value does not change when I change map extent. Can you take look on my expression? I'm very new to this. Many thanks!

var portal = Portal('https://www.arcgis.com');

var existingPoint = FeatureSetByPortalItem(
    portal,
    '...',
    0,
    [
        'IndoorWaterUse'
    ],
    True
);


var existingPoly = FeatureSetByPortalItem(
    portal,
    '...',
    0,
    [
        'OutdoorWaterUse'
    ],
    True
);


var out_fs = {
    geometryType: "",
    fields: [
    {name: "Indicator", type: "esriFieldTypeString"},
    {name: "Value", type: "esriFieldTypeDouble"},
    ],
    features: []
}

// Indicator 1:
var v = SUM(existingPoint,'IndoorWaterUse')
Push(out_fs.features, {attributes: {Indicator: "Indoor", Value: v}})

// Indicator 2:
var v = SUM(existingPoly,'OutdoorWaterUse')
Push(out_fs.features, {attributes: {Indicator: "Outdoor", Value: v}})

// ...

return Featureset(Text(out_fs))
 
0 Kudos