Arcade expression to calculate percentage?

308
1
03-29-2022 08:42 PM
Hayley
by
Occasional Contributor II

Hi there, 

I am trying to calculate the percentage of ethnic groups out of the entire population with an Arcade expression. This is what I have so far, any pointers on how to get this outputting a percentage rounded to 1 dp? Thanks! I am trying to do this in a Dashboards chart but figured there would be more Arcade support on this forum 🙂

 

#have connected to my portal and choosing the fields I want
var portal = Portal('https://arcgis.com');
var fs = FeatureSetByPortalItem(
    portal,
    '9b38b9f62ab74cb0aed6649d0f713cfa',
    0,
    [
        'C18_Ethnicity_L1_European',
        'PopCount_2018'
    ],
    false
);

#trying to sum the value of the two fields     
var european = Sum('C18_Ethnicity_L1_European')
var popcount = Sum('PopCount_2018')

#trying to calculate the percentage
var europeanperc = (european/popcount)*100

return FeatureSet(Number(europeanperc))

 

 

HL
0 Kudos
1 Reply
wayfaringrob
Frequent Contributor
0 Kudos