<?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 expression for Min, Max, Avg and Count in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175792#M46127</link>
    <description>&lt;P&gt;could you, please, tell me how to calculate each statistic by adding a new field on my buildings table and calculating the field?&lt;/P&gt;</description>
    <pubDate>Thu, 19 May 2022 23:37:55 GMT</pubDate>
    <dc:creator>User1RECS</dc:creator>
    <dc:date>2022-05-19T23:37:55Z</dc:date>
    <item>
      <title>Arcade expression for Min, Max, Avg and Count</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175489#M46113</link>
      <description>&lt;P&gt;I am working on the typology of urban blocks. Each block contains a number of buildings, each of which has an area and a height.&lt;BR /&gt;I would like to calculate the maximum, minimum, average and median area and height in each block on arcade. Can you help me please?&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 12:03:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175489#M46113</guid>
      <dc:creator>User1RECS</dc:creator>
      <dc:date>2022-05-19T12:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for Min, Max, Avg and Count</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175496#M46114</link>
      <description>&lt;UL&gt;&lt;LI&gt;You need a table with a block id, building height, and building area&lt;/LI&gt;&lt;LI&gt;You need one of the FeatureSetBy*() functions to load your building data&lt;/LI&gt;&lt;LI&gt;You need the GroupBy() function to group your building data by block id.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For the functions, look here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyid" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyid&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#groupby" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/arcade/function-reference/data_functions/#groupby&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example, you can use the following code in the&amp;nbsp;&lt;A href="https://developers.arcgis.com/arcade/playground/" target="_blank" rel="noopener"&gt;Playground | ArcGIS Arcade | ArcGIS Developer&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs_buildings = {
    "geometryType": "",
    "fields": [
        {"name": "BlockID", "type": "esriFieldTypeInteger"},
        {"name": "BuildingID", "type": "esriFieldTypeInteger"},
        {"name": "BuildingHeight", "type": "esriFieldTypeDouble"},
        {"name": "BuildingArea", "type": "esriFieldTypeDouble"}
        ],
    "features": [
        {"attributes": {"BlockID": 1, "BuildingID": 1, "BuildingHeight": 10., "BuildingArea": 300.}},
        {"attributes": {"BlockID": 1, "BuildingID": 2, "BuildingHeight": 30., "BuildingArea": 500.}},
        {"attributes": {"BlockID": 1, "BuildingID": 3, "BuildingHeight": 15., "BuildingArea": 250.}},
        {"attributes": {"BlockID": 2, "BuildingID": 4, "BuildingHeight": 16., "BuildingArea": 400.}},
        {"attributes": {"BlockID": 2, "BuildingID": 5, "BuildingHeight": 10., "BuildingArea": 300.}},
        {"attributes": {"BlockID": 3, "BuildingID": 6, "BuildingHeight": 10., "BuildingArea": 300.}}
        ]
}
fs_buildings = FeatureSet(Text(fs_buildings))
//return fs_buildings

// actually use one of the FeatureSetBy*() functions:
//var p = Portal(...)
//var fs_buildings = FeatureSetByPortalItem(p, item, layer, ["BlockID", "BuildingID", "BuildingHeight", "BuildingArea"], false)

var statistics = [
    {"name": "Count", "expression": "BuildingID", "statistic": "COUNT"},
    {"name": "HeightMax", "expression": "BuildingHeight", "statistic": "MAX"},
    {"name": "HeightMin", "expression": "BuildingHeight", "statistic": "MIN"},
    {"name": "HeightMean", "expression": "BuildingHeight", "statistic": "AVG"},
    {"name": "AreaMax", "expression": "BuildingArea", "statistic": "MAX"},
    {"name": "AreaMin", "expression": "BuildingArea", "statistic": "MIN"},
    {"name": "AreaMean", "expression": "BuildingArea", "statistic": "AVG"},
    ]
var fs_grouped_buildings = GroupBy(fs_buildings, "BlockID", statistics)
return fs_grouped_buildings&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 12:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175496#M46114</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-05-19T12:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for Min, Max, Avg and Count</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175520#M46117</link>
      <description>&lt;P&gt;Thank you very much for your quick response&lt;/P&gt;&lt;P&gt;in fact I already have a table with the BlockID, the ID of the buildings, the area and the height of each building. and I would like to calculate from this table.&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 13:13:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175520#M46117</guid>
      <dc:creator>User1RECS</dc:creator>
      <dc:date>2022-05-19T13:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for Min, Max, Avg and Count</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175792#M46127</link>
      <description>&lt;P&gt;could you, please, tell me how to calculate each statistic by adding a new field on my buildings table and calculating the field?&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 23:37:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175792#M46127</guid>
      <dc:creator>User1RECS</dc:creator>
      <dc:date>2022-05-19T23:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for Min, Max, Avg and Count</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175829#M46128</link>
      <description>&lt;P&gt;If you want to do this in the CalculateField tool, you can use this expression, modified for each statistic:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// load the whole feature class
var fs_buildings = FeatureSetByName($datastore, "BuildingFC", ["BlockID", "BuildingID", "BuildingHeight", "BuildingArea"], false)

// only select rows with the current feature's BlockID
var id = $feature.BlockID
var fs_buildings_block = Filter(fs_buildings, "BlockID = &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/354972"&gt;@ID&lt;/a&gt;")

// edit this line for each statistic and field
return Min(fs_buildings_block, "BuildingHeight")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 20 May 2022 04:48:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175829#M46128</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-05-20T04:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for Min, Max, Avg and Count</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175883#M46133</link>
      <description>&lt;P&gt;IT work...Thank you very much !!!!&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 10:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-min-max-avg-and-count/m-p/1175883#M46133</guid>
      <dc:creator>User1RECS</dc:creator>
      <dc:date>2022-05-20T10:34:28Z</dc:date>
    </item>
  </channel>
</rss>

