<?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: Creating a new field using Data Expression in Dashboard in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-new-field-using-data-expression-in/m-p/1537490#M61455</link>
    <description>&lt;P&gt;Thank you for your help! I played around with what you had told me and came up with something that actually worked! See script below. I really appreciate you taking the time to respond &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var fs = FeatureSetByPortalItem(&lt;BR /&gt;Portal('&lt;A href="https://xyz/portal" target="_blank"&gt;https://xyz/portal&lt;/A&gt;'),&lt;BR /&gt;'05b99d65195e41x5b1f49436eea53bfb',&lt;BR /&gt;0,&lt;BR /&gt;['PermitCurrentStatus', 'TotalLand', 'UndividedInterest'],&amp;nbsp;&lt;BR /&gt;false&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;// Define expressions for aggregation&lt;BR /&gt;var result = GroupBy(&lt;BR /&gt;fs,&lt;BR /&gt;['PermitCurrentStatus'],&amp;nbsp;&lt;BR /&gt;[&lt;BR /&gt;{&lt;BR /&gt;name: 'TotalLandSum',&lt;BR /&gt;expression: 'TotalLand',&lt;BR /&gt;statistic: 'SUM'&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;name: 'UndividedInterestSum',&lt;BR /&gt;expression: 'UndividedInterest',&lt;BR /&gt;statistic: 'SUM'&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;name: 'CalculatedValue',&lt;BR /&gt;expression: 'UndividedInterest / 100 * TotalLand',&lt;BR /&gt;statistic: 'SUM'&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;return result;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Sep 2024 18:46:31 GMT</pubDate>
    <dc:creator>LainieMcGannon</dc:creator>
    <dc:date>2024-09-11T18:46:31Z</dc:date>
    <item>
      <title>Creating a new field using Data Expression in Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-new-field-using-data-expression-in/m-p/1537087#M61440</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure this is even possible, but...&lt;/P&gt;&lt;P&gt;I am using a client's dataset which I can't edit, otherwise I would just create a new field in the actual data. I need to multiply one field by the percentage of another and display a table that shows GroupedBy status elements. Below is the code that I have so far...please let me know if there are any ideas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var fs = FeatureSetByPortalItem(&lt;BR /&gt;Portal('&lt;A href="https://xyz" target="_blank"&gt;https://xyz&lt;/A&gt;'),&lt;BR /&gt;'05b99d65195e41x5b1f49436eea53bfb',&lt;BR /&gt;0,&lt;BR /&gt;['PermitCurrentStatus', 'TotalLand', 'UndividedInterest'],&lt;BR /&gt;false&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;var field1 = 'TotalLand',&lt;BR /&gt;var field2 = 'UndividedInterest',&lt;BR /&gt;var trueacreage = field2/100 * field1&lt;/P&gt;&lt;P&gt;return GroupBy(fs, ['PermitCurrentStatus', 'UndividedInterest','TotalLand'],&lt;BR /&gt;[{name: 'TotalLand_count', expression: 'TotalLand', statistic: 'SUM'},&lt;BR /&gt;{name: 'trueacres', expression: 'trueacreage', statistic: 'SUM'},&lt;BR /&gt;{name: 'UndividedInterestCount', expression: 'UndividedInterest', statistic: 'SUM'}]);&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 20:45:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/creating-a-new-field-using-data-expression-in/m-p/1537087#M61440</guid>
      <dc:creator>LainieMcGannon</dc:creator>
      <dc:date>2024-09-10T20:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new field using Data Expression in Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-new-field-using-data-expression-in/m-p/1537167#M61444</link>
      <description>&lt;P&gt;It's possible but I'm not sure if it can be done as concisely as your group-by function there.&lt;/P&gt;&lt;P&gt;I think you might need to iterate through your feature set, derive each feature's new attribute one-by-one, construct a new feature and add it to a list, then convert your list to a feature set.&lt;/P&gt;&lt;P&gt;Deriving a new feature and adding it to a list would look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var featureList = [];
for (var feature in featureSet) {
  var newFeature = {
    attributes: {
      value1: feature.value1,
      value2: feature.value2,
      derived: feature.value1 / feature.value2
    }
  }
  Push(featureList, newFeature);
}&lt;/LI-CODE&gt;&lt;P&gt;Once you've got your new features in a list, you can return your new feature set by defining its schema like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var returnFeatureSetDict = {
  fields: [
        { name: "value1", type: "esriFieldTypeInteger" },
        { name: "value2", type: "esriFieldTypeInteger" },
        { name: "derived", type: "esriFieldTypeDouble" }
    ],
    "geometryType": "",
    "features": featureList
};
return FeatureSet(Text(returnFeatureSetDict));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(I'm not actually testing this code as I'm writing it, I'm just typing it freehand, so it might have some bugs but should get the pattern across.)&lt;/P&gt;&lt;P&gt;There very well could be a quicker way to do this, but I think this should work at least.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 02:08:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/creating-a-new-field-using-data-expression-in/m-p/1537167#M61444</guid>
      <dc:creator>MobiusSnake</dc:creator>
      <dc:date>2024-09-11T02:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new field using Data Expression in Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-new-field-using-data-expression-in/m-p/1537490#M61455</link>
      <description>&lt;P&gt;Thank you for your help! I played around with what you had told me and came up with something that actually worked! See script below. I really appreciate you taking the time to respond &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var fs = FeatureSetByPortalItem(&lt;BR /&gt;Portal('&lt;A href="https://xyz/portal" target="_blank"&gt;https://xyz/portal&lt;/A&gt;'),&lt;BR /&gt;'05b99d65195e41x5b1f49436eea53bfb',&lt;BR /&gt;0,&lt;BR /&gt;['PermitCurrentStatus', 'TotalLand', 'UndividedInterest'],&amp;nbsp;&lt;BR /&gt;false&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;// Define expressions for aggregation&lt;BR /&gt;var result = GroupBy(&lt;BR /&gt;fs,&lt;BR /&gt;['PermitCurrentStatus'],&amp;nbsp;&lt;BR /&gt;[&lt;BR /&gt;{&lt;BR /&gt;name: 'TotalLandSum',&lt;BR /&gt;expression: 'TotalLand',&lt;BR /&gt;statistic: 'SUM'&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;name: 'UndividedInterestSum',&lt;BR /&gt;expression: 'UndividedInterest',&lt;BR /&gt;statistic: 'SUM'&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;name: 'CalculatedValue',&lt;BR /&gt;expression: 'UndividedInterest / 100 * TotalLand',&lt;BR /&gt;statistic: 'SUM'&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;return result;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 18:46:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/creating-a-new-field-using-data-expression-in/m-p/1537490#M61455</guid>
      <dc:creator>LainieMcGannon</dc:creator>
      <dc:date>2024-09-11T18:46:31Z</dc:date>
    </item>
  </channel>
</rss>

