Select to view content in your preferred language

Dashboard Arcade sum statistic expression for two fields in same layer

504
1
01-14-2024 12:59 AM
LisaLisa
New Contributor

Working an operational dashboard to show working progress

I need an arcade expression for Dashboard that applies statistic SUM for fileds: Printed_Co & Digita_Co that are Rdy for PickUp or Complete/Delivered. 

LisaLisa_0-1705221864639.png

The result will be displayed in an indicator in the dashboard.

My arcade expression is like this:

// Reference layer using the FeatureSetByPortalItem() function.
var fs = FeatureSetByPortalItem(Portal('https://my-site.pr.portal'), 'b19q57894c8521f58e68t87412' , 0, ['Printed_Co', 'Digital_Co], false);

var sumPrintedCo = Sum(Filter($feature, Status in ['Complete/Delivered',  'Rdy for PickUp']), 'Printed_Co');
var sumDigitalCo = Sum(Filter($feature, Status in ['Complete/Delivered', 'Rdy for PickUp']), 'DigitalCo');

sumPrintedCo + sumDigitalCo

 

All I'm getting is: Invalid variable assignment

 

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

In the FeatureSetByPortalItem function, you have to include the "Status" field on the fields parameter when getting the FeatureSet and you were missing a closing quote for the Digital_Co field. The Filter function uses a FeatureSet as an input. You also have to put quotes around your filter expression and the "in" operator uses parentheses, not brackets.

 

// Reference layer using the FeatureSetByPortalItem() function.
var fs = FeatureSetByPortalItem(Portal('https://my-site.pr.portal'), 'b19q57894c8521f58e68t87412' , 0, ['Status', 'Printed_Co', 'Digital_Co'], false);

var sumPrintedCo = Sum(Filter(fs, "Status in ('Complete/Delivered', 'Rdy for PickUp')), 'Printed_Co');
var sumDigitalCo = Sum(Filter(fs, "Status in ('Complete/Delivered', 'Rdy for PickUp')), 'DigitalCo');

sumPrintedCo + sumDigitalCo