<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can you use a Data Expression to reference a layer filtered by a Category Selector? in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/can-you-use-a-data-expression-to-reference-a-layer/m-p/1266175#M7465</link>
    <description>&lt;P&gt;I believe I have found a solution, although it is a little cumbersome. I constructed a Data Expression that joins the fields I am filtering by (equipment name, region, operator) in the point layer to the relevant data I need from the related table. Now I can use the source and target field functions in the Selector since I have matching fields between the two datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var portal = Portal("https://www.arcgis.com/");
var pointFS = FeatureSetByPortalItem(
  portal,
  "portalID",
  0,
  ["tech","operator","country","record_date"],
  False
);

var tablefs = FeatureSetByPortalItem(
  portal,
  "portalID",
  1,
  ["*"],
  False
);

var features = [];
var feat;

for (var t in tablefs){
  var TableID = t["op_record_id"]
  for (var p in Filter(pointFS, "op_record_id ="+TableID)){
    feat = {
      attributes: {
        FeatureID: TableID,
        tech: p["tech"],
        operator: p["operator"],
        country: p["country"],
        device_group: t["device_group"],
        device_category: t["device_category"],
        quantity: t["quantity"],
      }
    }

    Push(features, feat)
  }
}

var joinedDict = {
  fields: [
    {name: "FeatureID", type: "esriFieldTypeString"},
    {name: "tech", type: "esriFieldTypeString"},
    {name: "operator", type: "esriFieldTypeString"},
    {name: "country", type: "esriFieldTypeString"},
    {name: "device_group", type: "esriFieldTypeString"},
    {name: "device_category", type: "esriFieldTypeString"},
    {name: "quantity", type: "esriFieldTypeInteger"},
  ],
  'geometryType':'',
  'features':features
};

return FeatureSet(Text(joinedDict));&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 09 Mar 2023 20:28:36 GMT</pubDate>
    <dc:creator>ZachLansford_HD</dc:creator>
    <dc:date>2023-03-09T20:28:36Z</dc:date>
    <item>
      <title>Can you use a Data Expression to reference a layer filtered by a Category Selector?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/can-you-use-a-data-expression-to-reference-a-layer/m-p/1266133#M7464</link>
      <description>&lt;P&gt;Is it possible to set up a Data Expression to reference a layer within the dashboard that is being filter by a Category Selector?&lt;/P&gt;&lt;P&gt;I have a dataset that is comprised of a point layer and a related table. The point layer represents a summary of a days work in the field with a particular piece of equipment - ex metal detector, backhoe, etc covering x area in y hours. There is a one to many relationship set up with a table that contains specifics about what possible items are being found in the field, with several fields categorizing the items as well as number of items found.&lt;/P&gt;&lt;P&gt;I have set up a dashboard with some Category Selectors that apply to the spatial point layer. Is there a way to set up a Data Expression where the filtered spatial layer also filters the indicators that are referencing the related table?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 18:43:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/can-you-use-a-data-expression-to-reference-a-layer/m-p/1266133#M7464</guid>
      <dc:creator>ZachLansford_HD</dc:creator>
      <dc:date>2023-03-09T18:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a Data Expression to reference a layer filtered by a Category Selector?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/can-you-use-a-data-expression-to-reference-a-layer/m-p/1266175#M7465</link>
      <description>&lt;P&gt;I believe I have found a solution, although it is a little cumbersome. I constructed a Data Expression that joins the fields I am filtering by (equipment name, region, operator) in the point layer to the relevant data I need from the related table. Now I can use the source and target field functions in the Selector since I have matching fields between the two datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var portal = Portal("https://www.arcgis.com/");
var pointFS = FeatureSetByPortalItem(
  portal,
  "portalID",
  0,
  ["tech","operator","country","record_date"],
  False
);

var tablefs = FeatureSetByPortalItem(
  portal,
  "portalID",
  1,
  ["*"],
  False
);

var features = [];
var feat;

for (var t in tablefs){
  var TableID = t["op_record_id"]
  for (var p in Filter(pointFS, "op_record_id ="+TableID)){
    feat = {
      attributes: {
        FeatureID: TableID,
        tech: p["tech"],
        operator: p["operator"],
        country: p["country"],
        device_group: t["device_group"],
        device_category: t["device_category"],
        quantity: t["quantity"],
      }
    }

    Push(features, feat)
  }
}

var joinedDict = {
  fields: [
    {name: "FeatureID", type: "esriFieldTypeString"},
    {name: "tech", type: "esriFieldTypeString"},
    {name: "operator", type: "esriFieldTypeString"},
    {name: "country", type: "esriFieldTypeString"},
    {name: "device_group", type: "esriFieldTypeString"},
    {name: "device_category", type: "esriFieldTypeString"},
    {name: "quantity", type: "esriFieldTypeInteger"},
  ],
  'geometryType':'',
  'features':features
};

return FeatureSet(Text(joinedDict));&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 09 Mar 2023 20:28:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/can-you-use-a-data-expression-to-reference-a-layer/m-p/1266175#M7465</guid>
      <dc:creator>ZachLansford_HD</dc:creator>
      <dc:date>2023-03-09T20:28:36Z</dc:date>
    </item>
  </channel>
</rss>

