I'm new to using Data Expressions in Dashboards. I'm not sure if what I'm trying to do is simple or complex. My data expression is from a similar dashboard from a colleague.
I'm creating a Table dashboard element that uses a data expression. Currently, I only have 5 records in my feature layer. Elsewhere in the dashboard, I have 3 Category Selectors which have Actions that filter data displayed in my Table element. The default selection for the Category Selectors would only display 3 records in the Table.
When I use FeatureSetByPortalItem in the data expression for the Table (shown below), it gets ALL records from the feature layer. How do I access only the records which are filtered by the Category Selectors? I'm iterating through the records to get the most recent record for a specific value in a field, but the result is a record which is not displayed (based on the Category Selectors).
var originalLayer = FeatureSetByPortalItem(
Portal('https://arcgis.com/'),
myFeatureLayerID,
0
);
When you create a dashboard element from a hosted feature layer, you connect it to all the data and then point category selectors at that element to create dynamic filters. Data expression work the same way. Your data expression should return all relevant data which is used to create a dashboard element, such as a table, and then you point the category selectors to the table element.
In order for your category selector to play nice with your table element, you need to ensure that your data expression returns the fields used in your category selector. For example, if I have a category selector to filter based on storm types (hail, snow, rain), then I need to ensure that my data expression returns a storm type field with corresponding values.