Select to view content in your preferred language

Dashboard Indicator Arcade Expression

1628
4
Jump to solution
02-14-2024 11:27 AM
Labels (1)
SeanT
by
Occasional Contributor

I'm seeking assistance with an arcade expression to show some data in a dashboard: Percent from two values in one field of a table to display in an indicator (matched / total).

If I could figure out how to do this without an expression I would be happy, but I don't think the indicator element is capable of calculating a percent.

 

var fs = FeatureSetByPortalItem(Portal('https://gisportal.company.com/portal'),
    'itemId',
    0,
    [
        'matched', //field name
    ],
    false
);
// Count of 'matched' by counting number of rows that are 'matched' and this one is giving me the execution error so can't even get to the next variable
var matched = Count(fs["matched"] == 'matched', 1, null);
// Total count of 'matched' and 'asset only', (this could be totally wrong) 
var total = Count((When(fs["matched"] == 'matched', 1, null)) + (When(fs["matched"] == 'asset only', 1, null))); 
          
var percentMatched = (matched / total) * 100;

return FeatureSet(percentMatched);

 

 

If it matters/helps, the 'matched' field has three values: matched, asset only, gis only.

Thanks

 

0 Kudos
2 Solutions

Accepted Solutions
JenniferAcunto
Esri Regular Contributor

You don't need to use a data expression for this. Just add your data to an indicator and filter it to provide your 'matched' value. Then toggle on the reference option and add your data without a filter to display the 'total' value. 

JenniferAcunto_0-1707941852110.png


Then on the Indicator tab, remove the {value} and {reference} fields and use the {} button to select {percentage}.

JenniferAcunto_1-1707941940239.png

 

- Jen

View solution in original post

SeanT
by
Occasional Contributor

Thank you so much! I am going to try this now.

View solution in original post

0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor

You have to return the value in a FeatureSet like this

return FeatureSet(Text({
  fields: [{name: 'the_percentage', type: 'esriFieldTypeSingle'}],
  geometryType: '',
  features: [{attributes:{the_percentage:percentMatched}}]
}))

 

SeanT
by
Occasional Contributor

I was pretty sure about the FeatureSet() part but getting the info for it was giving me trouble. May be able to do this without an expression based on the other response, so I'm going with it for now. Thanks!

0 Kudos
JenniferAcunto
Esri Regular Contributor

You don't need to use a data expression for this. Just add your data to an indicator and filter it to provide your 'matched' value. Then toggle on the reference option and add your data without a filter to display the 'total' value. 

JenniferAcunto_0-1707941852110.png


Then on the Indicator tab, remove the {value} and {reference} fields and use the {} button to select {percentage}.

JenniferAcunto_1-1707941940239.png

 

- Jen
SeanT
by
Occasional Contributor

Thank you so much! I am going to try this now.

0 Kudos