Select to view content in your preferred language

Arcade: Combining Two Feature Sets Based on A Shared Column for Dashboard Expression

612
1
04-24-2024 08:06 AM
Labels (1)
jackolcott
Emerging Contributor

Hello all - I am new to data expressions in ArcGIS dashboards, and have a question about combining two Feature Sets based on a shared column. 

I have a "spent" Feature Set and an "available" Feature Set. These two Feature Sets share a "Fiscal Year" column. The "spent" Feature Set was created using a groupBy expression.

I want to combine these two feature sets so that I can create a calculated field dividing spent/available. I want to then show the values of this calculated field in a dashboard indicator. 

jackolcott_0-1713970290994.png

See the below code for what I have so far. I can create the spent and available feature sets in the image above, but I don't know how to make the third table (output feature set) that combines the two. 

 

//create a feature set with the original non-aggregated data used for the spent featureset
var non_aggregated_spent_fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'xyz', '1')

//create a featureset with the data for the available featureset (this feature set is the "available" table in the image in my post)
var available_fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'xyz', '2')

//create a featureset with the aggregated data for the spent featureset. (this featureset is the "spent" table in the image in my post)
var spent_fs = GroupBy(non_aggregated_spent_fs, ['FiscalYear'], [ 
 {name: 'spent', expression: 'spentAmount', statistic: 'SUM' }]); 

//create a featureset that combines available_fs and spent_fs by the shared fiscal year column, and then create a calculated field column dividing spent/available

 

 

Thank you for taking the time to review this post. 

0 Kudos
1 Reply
Gaëtan_Lavenu
Occasional Contributor

Hi,

Why don't you create a joined hosted feature layer view ?
https://doc.arcgis.com/en/arcgis-online/manage-data/create-hosted-views.htm

0 Kudos