Good morning,
I’m looking for a sample that demonstrates how to use Arcade to count records from a hosted feature layer, specifically when connected through Dynamic Content in a text widget. I’m trying to understand how to access the data source and its fields using Arcade.
Essentially, I want to achieve the equivalent of COUNT("OBJECTID") in Arcade.
Hi @JoseSanchez,
You can refer to the examples here. https://doc.arcgis.com/en/experience-builder/latest/configure-widgets/advanced-formatting.htm
Thanks,
Ke
Good afternoon @Ke_Xu
I am looking for a way to implement this code from your link:
var ds = $dataSources["dataSource_id"].layer;
var distincItem = Distinct(ds, 'CNTRY_NAME'); return Count(distincItem);
Could you please explain to me how to add this line "var ds = $dataSources["dataSource_id"].layer;" from the default function generated in Experience Builder;? How do I find the dataSource_Id?
Found it!
There's no need to declare a function—just typing the code is enough.