Select to view content in your preferred language

ArcGIS Online Dashboard Data Expression — Still Grayed Out After Test Passes

96
2
Jump to solution
a week ago
Labels (1)
Cierra_Scriven
Occasional Contributor

Hi everyone,

I'm building an ArcGIS Online Dashboard for dynamic Capital Improvement Project Budget Snapshot, and trying to create a Data Expression using Arcade. I have three tables:

  • Appropriations (fields: projectguid, fundamount_sum)
  • Encumbrances (fields: projectguid, Total_Encumbrance)
  • Expenditures (fields: projectguid, costamount_sum)

Each table has about 350+ records. Every record represents a monetary value for a project that was created using a joined view between the project layer and it's funding or spending table, summarized as sums (except for Encumbrances, which is a separate table with a single hardlined value), matched across the tables by projectguid.

Goal:

I want to calculate the sum total Available Balance for all projects within an indicator element using the formula:

Available Balance = Appropriations - Encumbrances - Expenditures

 

Then I will use a List Element in the same dashboard to select the project I want to filter down to, which has a GlobalID that matches the projectguid. 

Problem:

    • My Arcade Data Expression runs successfully in "Test" (I get the expected features back).
    • But the expression is still grayed out and won't save in the Dashboard.
    • I have already added type: "FeatureSet" to my return.
    • I made sure all fields match the correct data types (String for projectID, Double for money fields).
    • I also cleaned my tables to remove records missing projectguid.
    • I use DefaultValue() to handle missing expenditures or encumbrances safely (treat missing values as 0).

My Code:

 

// Load the tables
var appropriationsTable = FeatureSetByPortalItem(
    Portal('https://www.arcgis.com'), 
    'REDACTED_APPROPRIATIONS_ITEM_ID', 
    0, 
    ['projectguid', 'fundamount_sum']
);

var encumbrancesTable = FeatureSetByPortalItem(
    Portal('https://www.arcgis.com'), 
    'REDACTED_ENCUMBRANCES_ITEM_ID', 
    0, 
    ['projectguid', 'Total_Encumbrance']
);

var expendituresTable = FeatureSetByPortalItem(
    Portal('https://www.arcgis.com'), 
    'REDACTED_EXPENDITURES_ITEM_ID', 
    0, 
    ['projectguid', 'costamount_sum']
);

// Create lookup dictionaries
var encumbranceDict = {};
for (var e in encumbrancesTable) {
    encumbranceDict[e.projectguid] = e.Total_Encumbrance;
}

var expenditureDict = {};
for (var exp in expendituresTable) {
    expenditureDict[exp.projectguid] = exp.costamount_sum;
}

// Build the new feature set
var features = [];
for (var a in appropriationsTable) {
    var projID = a.projectguid;

    if (!IsEmpty(projID)) {
        var appropriation = DefaultValue(a.fundamount_sum, 0);
        var encumbrance = DefaultValue(encumbranceDict[projID], 0);
        var expenditure = DefaultValue(expenditureDict[projID], 0);

        var availableBalance = (Number(appropriation) - Number(encumbrance) - Number(expenditure));

        Push(features, {
            attributes: {
                projectID: Text(projID),
                appropriations: appropriation,
                encumbrance: encumbrance,
                expenditures: expenditure,
                availableBalance: availableBalance
            }
        });
    }
}

// Return final FeatureSet
return {
    type: "FeatureSet",
    fields: [
        { name: "projectID", type: "esriFieldTypeString" },
        { name: "appropriations", type: "esriFieldTypeDouble" },
        { name: "encumbrance", type: "esriFieldTypeDouble" },
        { name: "expenditures", type: "esriFieldTypeDouble" },
        { name: "availableBalance", type: "esriFieldTypeDouble" }
    ],
    geometryType: "",
    features: features
};

 

What I’ve Checked:

  • All projects have a projectguid
  • Money fields are properly formatted numbers
  • Test results show 291 features returned
  • availableBalance math is correct
  • No missing required attributes

Question:


What else could cause a working Arcade Data Expression to remain grayed out in ArcGIS Dashboards, even after a successful test run?

Are there additional Arcade quirks or hidden Dashboard requirements I might be missing?

Thanks so much for any help or ideas!

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

In Dashboards, a Data Expression must return a FeatureSet. Your code is returning a dictionary, but that has to be to converted into a FeatureSet for it to be used in the Dashboard.

return FeatureSet({
    fields: [
        { name: "projectID", type: "esriFieldTypeString" },
        { name: "appropriations", type: "esriFieldTypeDouble" },
        { name: "encumbrance", type: "esriFieldTypeDouble" },
        { name: "expenditures", type: "esriFieldTypeDouble" },
        { name: "availableBalance", type: "esriFieldTypeDouble" }
    ],
    geometryType: "",
    features: features
});

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

In Dashboards, a Data Expression must return a FeatureSet. Your code is returning a dictionary, but that has to be to converted into a FeatureSet for it to be used in the Dashboard.

return FeatureSet({
    fields: [
        { name: "projectID", type: "esriFieldTypeString" },
        { name: "appropriations", type: "esriFieldTypeDouble" },
        { name: "encumbrance", type: "esriFieldTypeDouble" },
        { name: "expenditures", type: "esriFieldTypeDouble" },
        { name: "availableBalance", type: "esriFieldTypeDouble" }
    ],
    geometryType: "",
    features: features
});
Cierra_Scriven
Occasional Contributor

You're absolutely right. I had thought I had FeatureSet in there and did not. Thank you!

0 Kudos