<?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 Expression Fields in Advanced views in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/expression-fields-in-advanced-views/m-p/1123228#M4018</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I am trying to create an advanced view according to this documentation&amp;nbsp;&lt;A title="Advanced views" href="https://developers.arcgis.com/rest/services-reference/enterprise/add-to-definition-feature-service-.htm" target="_blank" rel="noopener"&gt;Advanced views&lt;/A&gt;&amp;nbsp;, this is my code:&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;{
  "layers": [
    {
      "name": "VistaAvanzada",
      "description": "AttributeJoin",
      "adminLayerInfo": {
        "viewLayerDefinition": {
          "table": {
            "name": "target",
            "sourceServiceName": "TestJoinExpression_Tabla1",
            "sourceLayerId": 0,
            "sourceLayerFields": [
              {
                "name": "key1",
                "alias": "key1",
                "source": "key1"
              },
              {
                "name": "date1",
                "alias": "date1",
                "source": "date1"
              }
            ],
            "relatedTables": [
              {
                "name": "joined",
                "sourceServiceName": "TestJoinExpression_Tabla2",
                "sourceLayerId": 0,
                "sourceLayerFields": [
                  {
                    "name": "key1related",
                    "alias": "key1related",
                    "source": "key1related"
                  },
                  {
                    "name": "name",
                    "alias": "name",
                    "source": "name"
                  },
                  {
                    "name": "relatedExpression",
                    "alias": "SumNumsTest",
                    "expression": "Num1 + Num2",
                    "type": "esriFieldTypeInteger"
                  }
                ],
                "type": "INNER",
                "parentKeyFields": [
                  "key1",
                  "key2"
                ],
                "keyFields": [
                  "key1related",
                  "key2related"
                ]
              }
            ]
          }
        }
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;For this test, I have created the fields Num1 and Num2, in both tables, because I am not sure how the expression works,&amp;nbsp;however the expression field "relatedExpression" is not created, I can see the fields I declared, coming from both tables. That is, the view works for me as a union of tables, but I cannot create the additional field that corresponds to the expression.&lt;/P&gt;&lt;P&gt;I appreciate the help&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 02:09:13 GMT</pubDate>
    <dc:creator>AdministradorData_Gis</dc:creator>
    <dc:date>2021-12-07T02:09:13Z</dc:date>
    <item>
      <title>Expression Fields in Advanced views</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/expression-fields-in-advanced-views/m-p/1123228#M4018</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I am trying to create an advanced view according to this documentation&amp;nbsp;&lt;A title="Advanced views" href="https://developers.arcgis.com/rest/services-reference/enterprise/add-to-definition-feature-service-.htm" target="_blank" rel="noopener"&gt;Advanced views&lt;/A&gt;&amp;nbsp;, this is my code:&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;{
  "layers": [
    {
      "name": "VistaAvanzada",
      "description": "AttributeJoin",
      "adminLayerInfo": {
        "viewLayerDefinition": {
          "table": {
            "name": "target",
            "sourceServiceName": "TestJoinExpression_Tabla1",
            "sourceLayerId": 0,
            "sourceLayerFields": [
              {
                "name": "key1",
                "alias": "key1",
                "source": "key1"
              },
              {
                "name": "date1",
                "alias": "date1",
                "source": "date1"
              }
            ],
            "relatedTables": [
              {
                "name": "joined",
                "sourceServiceName": "TestJoinExpression_Tabla2",
                "sourceLayerId": 0,
                "sourceLayerFields": [
                  {
                    "name": "key1related",
                    "alias": "key1related",
                    "source": "key1related"
                  },
                  {
                    "name": "name",
                    "alias": "name",
                    "source": "name"
                  },
                  {
                    "name": "relatedExpression",
                    "alias": "SumNumsTest",
                    "expression": "Num1 + Num2",
                    "type": "esriFieldTypeInteger"
                  }
                ],
                "type": "INNER",
                "parentKeyFields": [
                  "key1",
                  "key2"
                ],
                "keyFields": [
                  "key1related",
                  "key2related"
                ]
              }
            ]
          }
        }
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;For this test, I have created the fields Num1 and Num2, in both tables, because I am not sure how the expression works,&amp;nbsp;however the expression field "relatedExpression" is not created, I can see the fields I declared, coming from both tables. That is, the view works for me as a union of tables, but I cannot create the additional field that corresponds to the expression.&lt;/P&gt;&lt;P&gt;I appreciate the help&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 02:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/expression-fields-in-advanced-views/m-p/1123228#M4018</guid>
      <dc:creator>AdministradorData_Gis</dc:creator>
      <dc:date>2021-12-07T02:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Fields in Advanced views</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/expression-fields-in-advanced-views/m-p/1275616#M4447</link>
      <description>&lt;P&gt;It has been 2 years so I am not sure if you already have it fixed yet, but I got it solved by adding "source" property to field object referring to at least one field whose value being used in the expression, then the field displayed normally.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[
  { // calculate value on single field
    "name": "testField",
    "type": "esriFieldTypeInteger",
    "alias": "testField",
    "expression": "myNumberField1 * 2",
    "source": "myNumberField1"
  },
  { // calculate value on multiple fields, only one field needed in source
    "name": "testField2",
    "type": "esriFieldTypeInteger",
    "alias": "testField2",
    "expression": "myNumberField1 + myNumberField2",
    "source": "myNumberField1"
  },
  { // calculate static value for all records, source field must be there even it is irrelevant
    "name": "testField3",
    "type": "esriFieldTypeString",
    "alias": "testField3",
    "expression": "'Hello World!'",
    "source": "OBJECTID"
  },
  { // example of advanced SQL to get hour part from date field
    "name": "hourOfDay",
    "type": "esriFieldTypeInteger",
    "alias": "hourOfDay",
    "expression": "DATEPART(HOUR, myDateField)",
    "source": "myDateField"
  }
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 02:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/expression-fields-in-advanced-views/m-p/1275616#M4447</guid>
      <dc:creator>ponlawat_w</dc:creator>
      <dc:date>2023-04-05T02:21:13Z</dc:date>
    </item>
  </channel>
</rss>

