<?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: Data Expression to join two layers results in &amp;quot;Invalid data type for expression&amp;quot; in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1636022#M11308</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;When posting code, use the "&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633#U1007633" target="_self"&gt;Insert/Edit code sample&lt;/A&gt;" button instead of attaching it as a text file. It's much easier to read and make reference to.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks for the suggestion. It's my first post so I wasn't aware of that option &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I've made that update now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;It looks like the "service_order_number" field isn't a numeric field, but rather a text field, so the Filter expression would need quotes around the variable. Try using this line instead&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="javascript"&gt;for (var p in Filter(surveys, "service_order_number = @tableID")) {&lt;/LI-CODE&gt;&lt;P&gt;Using variable substitution (see the Filter function &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#filter" target="_self"&gt;documentation&lt;/A&gt;) will automatically take care of whether quote are required around the variable.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;That's correct, they're both text fields I'm trying to join by. I made the suggested change and now I get a new error:&lt;STRONG&gt; "&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;Cannot read properties of null (reading 'toString')"&lt;/STRONG&gt; Which must be because some of the points have a null service order number? Taking a look at that next.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jul 2025 17:03:19 GMT</pubDate>
    <dc:creator>delozar_EMWD</dc:creator>
    <dc:date>2025-07-24T17:03:19Z</dc:date>
    <item>
      <title>Data Expression to join two layers results in "Invalid data type for expression"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1635764#M11305</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm attempting to create a data expression that joins a hosted feature layer to a layer within a map image layer based on a shared ID, to be used in a dashboard indicator element. Enterprise 11.1.&lt;/P&gt;&lt;P&gt;A little background: We're creating a workflow where field users open Field Maps, choose a point from the map image layer, launch Survey123 from an attribute expression in the pop-up, relevant attributes are brought over from the point and then the field users capture information on the asset's location. A survey needs to be performed for every point. Management wants to be able to see the progress of how many surveys have been completed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been fiddling around with the arcade expression provided &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard/dashboard_data/JoinLayerFieldsToTable.md" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;and kept having timeout issues until I changed the layers to only bring in one or two fields instead of "*" aka, all of them. Now, I get "Invalid data type for expression" which makes me think I'm on the right path but still missing something.&amp;nbsp; The field it's refencing is coming from the hosted feature layer (survey results).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delozar_EMWD_0-1753307666185.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137103iD1003F2EE5CC7C1A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="delozar_EMWD_0-1753307666185.png" alt="delozar_EMWD_0-1753307666185.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe I'm overcomplicating how this can be done? Any thoughts are welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;//portal connection
var prtl = Portal("URL HERE");

//survey results point layer
var surveys = FeatureSetByPortalItem(
    prtl,
    "ITEM ID HERE",
    0,
    ['globalid','objectid','service_order_number', 'backflow_required'],
    false
);

//water service point layer
var services = FeatureSetByPortalItem(
    prtl,
    "ITEM ID HERE",
    0,
    ['globalid','objectid','SERVICE_ORDER_NUMBER'],
    false
);

// Create empty features array and feat object
var features = [];
var feat;

// Populate Feature Array
for (var t in services) {
    var tableID = t["SERVICE_ORDER_NUMBER"]
    for (var p in Filter(surveys, "service_order_number = "+tableID)){
        feat = {
            attributes: {
                SERVICE_ORDER_NUMBER: tableID,
                Backflow_Required: p["backflow_required"],
            }
        }

    Push(features, feat)
    }
}

var joinedDict = {
    fields: [
        { name: "SERVICE_ORDER_NUMBER", type: "esriFieldTypeString" },
        { name: "Backflow_Required", type: "esriFieldTypeString" },
    ],
    'geometryType': '',
    'features':features
};

// Return dictionary cast as a feature set 
return FeatureSet(Text(joinedDict));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 16:22:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1635764#M11305</guid>
      <dc:creator>delozar_EMWD</dc:creator>
      <dc:date>2025-07-24T16:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression to join two layers results in "Invalid data type for expression"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1635902#M11306</link>
      <description>&lt;P&gt;When posting code, use the "&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633#U1007633" target="_self"&gt;Insert/Edit code sample&lt;/A&gt;" button instead of attaching it as a text file. It's much easier to read and make reference to.&lt;/P&gt;&lt;P&gt;It looks like the "service_order_number" field isn't a numeric field, but rather a text field, so the Filter expression would need quotes around the variable. Try using this line instead&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for (var p in Filter(surveys, "service_order_number = @tableID")) {&lt;/LI-CODE&gt;&lt;P&gt;Using variable substitution (see the Filter function &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#filter" target="_self"&gt;documentation&lt;/A&gt;) will automatically take care of whether quote are required around the variable.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 12:49:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1635902#M11306</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-07-24T12:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression to join two layers results in "Invalid data type for expression"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1636022#M11308</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;When posting code, use the "&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633#U1007633" target="_self"&gt;Insert/Edit code sample&lt;/A&gt;" button instead of attaching it as a text file. It's much easier to read and make reference to.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks for the suggestion. It's my first post so I wasn't aware of that option &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I've made that update now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;It looks like the "service_order_number" field isn't a numeric field, but rather a text field, so the Filter expression would need quotes around the variable. Try using this line instead&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="javascript"&gt;for (var p in Filter(surveys, "service_order_number = @tableID")) {&lt;/LI-CODE&gt;&lt;P&gt;Using variable substitution (see the Filter function &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#filter" target="_self"&gt;documentation&lt;/A&gt;) will automatically take care of whether quote are required around the variable.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;That's correct, they're both text fields I'm trying to join by. I made the suggested change and now I get a new error:&lt;STRONG&gt; "&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;Cannot read properties of null (reading 'toString')"&lt;/STRONG&gt; Which must be because some of the points have a null service order number? Taking a look at that next.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 17:03:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1636022#M11308</guid>
      <dc:creator>delozar_EMWD</dc:creator>
      <dc:date>2025-07-24T17:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression to join two layers results in "Invalid data type for expression"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1636096#M11310</link>
      <description>&lt;P&gt;You can check whether the service order number is empty before the filtering the FeatureSet&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for (var t in services) {
  var tableID = t["SERVICE_ORDER_NUMBER"];
  if (!IsEmpty(tableID)) {
    for (var p in Filter(surveys, "service_order_number = @tableID")) {
      feat = {
        attributes:
          {
            SERVICE_ORDER_NUMBER: tableID,
            Backflow_Required: p["backflow_required"]
          }
      };

      Push(features, feat);
    }
  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 24 Jul 2025 18:53:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-join-two-layers-results-in-quot/m-p/1636096#M11310</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-07-24T18:53:11Z</dc:date>
    </item>
  </channel>
</rss>

