<?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: Arcade joined tables: joinKey in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-joined-tables-joinkey/m-p/1151332#M52474</link>
    <description>&lt;P&gt;Thanks!&lt;BR /&gt;I submitted an idea about improving the docs here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/developers-ideas/arcade-documentation-joined-tables/idi-p/1151331" target="_self"&gt;Arcade Documentation: Joined Tables&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2022 16:36:46 GMT</pubDate>
    <dc:creator>Bud</dc:creator>
    <dc:date>2022-03-07T16:36:46Z</dc:date>
    <item>
      <title>Arcade joined tables: joinKey</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-joined-tables-joinkey/m-p/1151241#M52455</link>
      <description>&lt;P&gt;The Arcade developer FAQ says this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/guide/faq/#how-do-i-reference-data-from-a-joined-table" target="_self"&gt;How do I reference data from a joined table?&lt;/A&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;You can reference attribute data from a joined table using the square bracket syntax for referencing field names:&amp;nbsp; $feature["&lt;STRONG&gt;joinKey&lt;/STRONG&gt;.fieldName"].&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;// data from a joined table&lt;/SPAN&gt;
&lt;SPAN class=""&gt;var&lt;/SPAN&gt; demVotes2016 = &lt;SPAN class=""&gt;$feature&lt;/SPAN&gt;[&lt;SPAN class=""&gt;"COUNTY_ID.VOTED_DEM_2016"&lt;/SPAN&gt;];
&lt;SPAN class=""&gt;var&lt;/SPAN&gt; demVotes2012 = &lt;SPAN class=""&gt;$feature&lt;/SPAN&gt;[&lt;SPAN class=""&gt;"COUNTY_ID.VOTED_DEM_2012"&lt;/SPAN&gt;];

&lt;SPAN class=""&gt;// returns % change in votes from 2012 to 2016&lt;/SPAN&gt;
&lt;SPAN class=""&gt;Round&lt;/SPAN&gt;( ( ( demVotes2016 - demVotes2012 ) / demVotes2012 ) * &lt;SPAN class=""&gt;100&lt;/SPAN&gt;, &lt;SPAN class=""&gt;2&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. Where does the joinKey come from? &lt;/STRONG&gt;Is it using a relationship class? Or an in-map join in a project file?&lt;BR /&gt;2. Does it only work if the two join fields have the same name?&lt;BR /&gt;3. How is this related to FeatureSets?&lt;BR /&gt;4. Where can we find more info?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 16:33:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-joined-tables-joinkey/m-p/1151241#M52455</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2022-03-07T16:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade joined tables: joinKey</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-joined-tables-joinkey/m-p/1151278#M52460</link>
      <description>&lt;P&gt;This seems misleading...&lt;/P&gt;&lt;P&gt;If you have a &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/add-join.htm" target="_self"&gt;joined table&lt;/A&gt;, you have to reference the fields with "TableName.FieldName". This applies to Arcade and to Python (field calculation and labeling). The join field shouldn't play a role in this.&lt;/P&gt;&lt;P&gt;In the documentation's example, they probably have a feature class "Counties" with the primary key "CountyID" and a table "ElectionResults" with the fields "CountyID" (linking the table to the feature class), "VotedDem2012" and "VotedDem2016". They then joined the table to the feature class using "CountyID" as join field. To display the vote change in the layer's popup, you would then use this expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var demVotes2016 = $feature["ElectionResults.VotedDem2016"];  // table name, not key
var demVotes2012 = $feature["ElectionResults.VotedDem2012"];

// returns % change in votes from 2012 to 2016
Round( ( ( demVotes2016 - demVotes2012 ) / demVotes2012 ) * 100, 2);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The join key shouldn't have anything to do with this. It is used to link two tables to each other and is chosen by the data owner when designing the tables / database. In database lingo they're called primary key and foreign key. In the ArcGIS environments, it can be used for joins, relates, and relationship classes.&lt;/LI&gt;&lt;LI&gt;see above&lt;/LI&gt;&lt;LI&gt;This has some impact on feature sets:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//If you have a relationship class between two tables, you can get the related records of a feature using the FeatureSetByRelationshipName() function.
var related_features = FeatureSetByRelationshipName($feature, "RelationshipName")

//If you don't have a relationship class, but still have the key fields, you can Filter() a feature set for the related records.
var related_fs = FeatureSetByName(...)
var primary_key = $feature.PrimaryKey
var related_features = Filter(related_fs, "ForeignKey = @primary_key")

//If you load a joined feature set (e.g. using the $map global or from a feature service), you have to use the bracket notation and you have to fully qualify the field names.
var joined_table = FeatureSetByName(...)
var f = First(joined_table)
// these won't work
// f.Field
// f["Field"]
// This could work
f["TableName.Field"]
// It could be that you have to _fully_ qualify the field name by using the names of the database and the dataowner:
f["DatabaseName.DataOwnerName.TableName.Field"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 15:13:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-joined-tables-joinkey/m-p/1151278#M52460</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-07T15:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade joined tables: joinKey</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-joined-tables-joinkey/m-p/1151332#M52474</link>
      <description>&lt;P&gt;Thanks!&lt;BR /&gt;I submitted an idea about improving the docs here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/developers-ideas/arcade-documentation-joined-tables/idi-p/1151331" target="_self"&gt;Arcade Documentation: Joined Tables&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 16:36:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-joined-tables-joinkey/m-p/1151332#M52474</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2022-03-07T16:36:46Z</dc:date>
    </item>
  </channel>
</rss>

