<?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 Arcade Expressions &amp;amp; Maths returning wrong values in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320657#M72308</link>
    <description>&lt;P&gt;I'm using Arcade Expressions to add up to fields of data Field A + Field B then divide by 2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far the expression works for all data apart from when Field A or Field B contain a 0 then all I get as an output is 0 when actually it should be a value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm following the standard rules of BODMAS so I have (Field A + Field B) /2 which when I verify is a valid formula so don't know why this is happening.&amp;nbsp;&lt;/P&gt;&lt;P&gt;See attached snip to see the formula&lt;/P&gt;</description>
    <pubDate>Mon, 21 Aug 2023 13:36:53 GMT</pubDate>
    <dc:creator>AndrewReynoldsDevon</dc:creator>
    <dc:date>2023-08-21T13:36:53Z</dc:date>
    <item>
      <title>Arcade Expressions &amp; Maths returning wrong values</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320657#M72308</link>
      <description>&lt;P&gt;I'm using Arcade Expressions to add up to fields of data Field A + Field B then divide by 2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far the expression works for all data apart from when Field A or Field B contain a 0 then all I get as an output is 0 when actually it should be a value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm following the standard rules of BODMAS so I have (Field A + Field B) /2 which when I verify is a valid formula so don't know why this is happening.&amp;nbsp;&lt;/P&gt;&lt;P&gt;See attached snip to see the formula&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 13:36:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320657#M72308</guid>
      <dc:creator>AndrewReynoldsDevon</dc:creator>
      <dc:date>2023-08-21T13:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expressions &amp; Maths returning wrong values</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320668#M72310</link>
      <description>&lt;P&gt;I would try wrapping each field in Number(). What data type are the two fields?&lt;/P&gt;&lt;P&gt;(Number($feature.PassengersOutward) + Number($feature.Passengerslnward)) / 2&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 13:56:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320668#M72310</guid>
      <dc:creator>ClayDonaldsonSWCA</dc:creator>
      <dc:date>2023-08-21T13:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expressions &amp; Maths returning wrong values</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320729#M72315</link>
      <description>&lt;P&gt;I tried the above but I'm still getting calculated values of 0 where one of the data values is 0.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The datatypes are doubles with numeric formatting. The output of the Arcade expression is data type 'Long'. There are 29 records out of 1900 that have a 0 value in one of the fields so the others have data values greater than 1 &amp;amp; the equation is working ok for those.&amp;nbsp;&lt;/P&gt;&lt;P&gt;See the code below&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;(Number($feature.PassengersOutward) + Number($feature.PassengersInward)) /2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 15:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320729#M72315</guid>
      <dc:creator>AndrewReynoldsDevon</dc:creator>
      <dc:date>2023-08-21T15:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expressions &amp; Maths returning wrong values</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320737#M72317</link>
      <description>&lt;P&gt;I can't reproduce the error, but you might want to try these:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// your output field is an integer, try rounding
Round(($feature.PassengersOutward + $feature.Passengerslnward) / 2)

// try using the Mean() function
Mean([$feature.PassengersOutward, $feature.Passengerslnward])

// try both
Round(Mean([$feature.PassengersOutward, $feature.Passengerslnward]))&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 21 Aug 2023 15:34:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320737#M72317</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-08-21T15:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expressions &amp; Maths returning wrong values</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320739#M72318</link>
      <description>&lt;P&gt;What is the value in the other field for those 29 records? If it's 1, the resulting value would be 0.5, which, in a long integer field, would show as 0.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 15:38:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1320739#M72318</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-21T15:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expressions &amp; Maths returning wrong values</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1321071#M72342</link>
      <description>&lt;P&gt;The other values are 0 so the answer should be 0.5 so the data type of the field must be the issue.&amp;nbsp; I'm using model builder to add the field before the calculation. What option should I choose from the data type drop down so that the above problem is resolved?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 11:06:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1321071#M72342</guid>
      <dc:creator>AndrewReynoldsDevon</dc:creator>
      <dc:date>2023-08-22T11:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expressions &amp; Maths returning wrong values</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1321137#M72348</link>
      <description>&lt;P&gt;You should use Float. Take a look at the documentation about &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/arcgis-field-data-types.htm" target="_self"&gt;field data types&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 13:44:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expressions-amp-maths-returning-wrong/m-p/1321137#M72348</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-22T13:44:21Z</dc:date>
    </item>
  </channel>
</rss>

