Select to view content in your preferred language

Use Arcade to show maximum/min/avg for more than one record?

1165
7
Jump to solution
06-13-2022 06:50 AM
RandyMcGregor3
Frequent Contributor

I need to show minimum and maximum values for a series of measurements associated with unique location.

I thought "max" and "min" would do the trick, but for both lists and indicators, I am only getting a result for each record. 

Both the list and the indicator are filtered and should have a discreet number of records that I would like to get statistics for.

Is it possible to do this? I have a bad feeling that I am overlooking something obvious 😞

Thank you for your time,

Randy McGregor

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

So if we had a data expression that grouped the records per-location, that could be enough? Try something like this, then set the indicator to Features. This should give you the three statistics for a given location. It won't aggregate across multiple locations, though, if that's an issue.

var fs = FeatureSetByPortalItem(
    Portal('url'),
    'itemID',
    1, // or whatever layer index this table is at. I'm assuming it's a related table?
    ['measurement-field', 'location-id'],
    false
)

return GroupBy(
    fs,
    'location-id',
    [
        {
            name: 'minimum',
            expression: 'measurement-field',
            statistic: 'MIN'
        },
        {
            name: 'maximum',
            expression: 'measurement-field',
            statistic: 'MAX'
        },
        {
            name: 'average',
            expression: 'measurement-field',
            statistic: 'AVG'
        }
    ]
)

 

- Josh Carlson
Kendall County GIS

View solution in original post

7 Replies
jcarlson
MVP Esteemed Contributor

An indicator should be able to show the min / max for multiple features without the need for Arcade at all. How do you have your indicator configured?

- Josh Carlson
Kendall County GIS
0 Kudos
RandyMcGregor3
Frequent Contributor

Thank you for your reply. An indicator can do this for one chosen statistic when you select 'statistic' rather than 'feature' . I can make three indicators (one for max, one for min, and one for avg), and that would not be bad. Trying to avoid that, but may end up doing that.

I would like to enter the min value at the top, the avg value in the middle and the max value at the bottom, of the indicator, but this seems to just act on the current record.

0 Kudos
jcarlson
MVP Esteemed Contributor

Ah, yes. You could get two statistics using a reference value, but to get all three in one indicator, you'd need to use a Data Expression.

Are you hoping to make this indicator interactive and filterable by feature selections elsewhere?

- Josh Carlson
Kendall County GIS
0 Kudos
RandyMcGregor3
Frequent Contributor

Yes, the indicator needs to be interactive. The dashboard is filtered by a url parameter configured in the dashboard, and needs to show results for the selected location.

Thank you,

Randy McGregor

0 Kudos
jcarlson
MVP Esteemed Contributor

So if we had a data expression that grouped the records per-location, that could be enough? Try something like this, then set the indicator to Features. This should give you the three statistics for a given location. It won't aggregate across multiple locations, though, if that's an issue.

var fs = FeatureSetByPortalItem(
    Portal('url'),
    'itemID',
    1, // or whatever layer index this table is at. I'm assuming it's a related table?
    ['measurement-field', 'location-id'],
    false
)

return GroupBy(
    fs,
    'location-id',
    [
        {
            name: 'minimum',
            expression: 'measurement-field',
            statistic: 'MIN'
        },
        {
            name: 'maximum',
            expression: 'measurement-field',
            statistic: 'MAX'
        },
        {
            name: 'average',
            expression: 'measurement-field',
            statistic: 'AVG'
        }
    ]
)

 

- Josh Carlson
Kendall County GIS
RandyMcGregor3
Frequent Contributor

I missed this response. Thanks for this. This looks interesting. I'll see if it works. I need to provide these three numbers for whatever location a user selects. Currently, I have added these fields to the input with a summarize/join field combination. I think this will work fine. I appreciate your help.

0 Kudos
RandyMcGregor3
Frequent Contributor

Had a chance to look at this, and this will work for me. Thank you very much for your help.

0 Kudos