<?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 Directly Reference Select_One In Calculation in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/directly-reference-select-one-in-calculation/m-p/819656#M15465</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since the select_one question type does not support 'bind::type = int or decimal' at the moment and only returns a string value, currently a hidden or calculate question need to be added to convert the string to numeric values, if a following mathematical equation need to reference the select_one question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's a method to directly reference the select_one question in a mathematical&amp;nbsp;equation, using the 'number()' function. The 'number()' function converts string value to numeric value, and moreover, it returns the value '0' when the question being referenced is unanswered.&amp;nbsp;My current finding is, the question (select_one or calculate) being referenced has to be a string field type, otherwise the 'number()' function will return an empty value if the referenced question has not been answered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is confusing, if&amp;nbsp;number('') = 0, why&amp;nbsp;number(NaN) = NaN?&lt;/P&gt;&lt;P&gt;Edit: Perhaps&amp;nbsp;NaN is treated as Number in XML, and number() does not convert numeric value. But that still doesn't explain why number('') = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This method is very useful when we need to include answers of many non-required questions in a complex calculation, because the usual method (using a hidden question for&amp;nbsp;conversion) not only creating many fields but also would return a NaN value (unanswered question) and fail the calculation - this can be&amp;nbsp;solved by using a 'coalesce(${question},0)' statement by the way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My concern is, is there any pitfall or bug in this method and cause it not working? Especially when the select_one question is unanswered and returns an empty value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="482183" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/482183_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="482184" class="image-2 jive-image" height="104" src="https://community.esri.com/legacyfs/online/482184_pastedImage_2.png" width="300" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any comment would be greatly appreciated.&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3966"&gt;Ismael Chivite&lt;/A&gt;&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/346771"&gt;Jim Moore&lt;/A&gt;&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/382776"&gt;Ben Turrell&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Sun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Feb 2020 01:57:13 GMT</pubDate>
    <dc:creator>Jing_Sun</dc:creator>
    <dc:date>2020-02-14T01:57:13Z</dc:date>
    <item>
      <title>Directly Reference Select_One In Calculation</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/directly-reference-select-one-in-calculation/m-p/819656#M15465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since the select_one question type does not support 'bind::type = int or decimal' at the moment and only returns a string value, currently a hidden or calculate question need to be added to convert the string to numeric values, if a following mathematical equation need to reference the select_one question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's a method to directly reference the select_one question in a mathematical&amp;nbsp;equation, using the 'number()' function. The 'number()' function converts string value to numeric value, and moreover, it returns the value '0' when the question being referenced is unanswered.&amp;nbsp;My current finding is, the question (select_one or calculate) being referenced has to be a string field type, otherwise the 'number()' function will return an empty value if the referenced question has not been answered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is confusing, if&amp;nbsp;number('') = 0, why&amp;nbsp;number(NaN) = NaN?&lt;/P&gt;&lt;P&gt;Edit: Perhaps&amp;nbsp;NaN is treated as Number in XML, and number() does not convert numeric value. But that still doesn't explain why number('') = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This method is very useful when we need to include answers of many non-required questions in a complex calculation, because the usual method (using a hidden question for&amp;nbsp;conversion) not only creating many fields but also would return a NaN value (unanswered question) and fail the calculation - this can be&amp;nbsp;solved by using a 'coalesce(${question},0)' statement by the way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My concern is, is there any pitfall or bug in this method and cause it not working? Especially when the select_one question is unanswered and returns an empty value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="482183" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/482183_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="482184" class="image-2 jive-image" height="104" src="https://community.esri.com/legacyfs/online/482184_pastedImage_2.png" width="300" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any comment would be greatly appreciated.&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3966"&gt;Ismael Chivite&lt;/A&gt;&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/346771"&gt;Jim Moore&lt;/A&gt;&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/382776"&gt;Ben Turrell&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Sun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2020 01:57:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/directly-reference-select-one-in-calculation/m-p/819656#M15465</guid>
      <dc:creator>Jing_Sun</dc:creator>
      <dc:date>2020-02-14T01:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Directly Reference Select_One In Calculation</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/directly-reference-select-one-in-calculation/m-p/819657#M15466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/369352"&gt;Jing Sun&lt;/A&gt;‌, it looks like &lt;A href="https://community.esri.com/migrated-users/3263"&gt;James Tedrick&lt;/A&gt;‌ has responded to a similar question on a separate post - just including the link to it here for the benefit of other visitors to this thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="link-titled" href="https://community.esri.com/message/910168-re-addition-calculations-not-working#comment-908591" title="https://community.esri.com/message/910168-re-addition-calculations-not-working#comment-908591"&gt;https://community.esri.com/message/910168-re-addition-calculations-not-working#comment-908591&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Cheers,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2020 05:00:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/directly-reference-select-one-in-calculation/m-p/819657#M15466</guid>
      <dc:creator>Jim-Moore</dc:creator>
      <dc:date>2020-02-20T05:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Directly Reference Select_One In Calculation</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/directly-reference-select-one-in-calculation/m-p/819658#M15467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To summarise:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Number(${question}) = 0&amp;nbsp; when ${question} is a string question &amp;amp; returns an empty string ('').&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Number(${question}) =&amp;nbsp;NaN when ${question} is a&amp;nbsp;integer/decimal question &amp;amp; returns an empty&amp;nbsp;value (NaN). My research shows that an empty value (NaN)&amp;nbsp;is treated as a numeric value, and number() does nothing to the numeric value, hence the output is NaN if the input is NaN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2020 07:24:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/directly-reference-select-one-in-calculation/m-p/819658#M15467</guid>
      <dc:creator>Jing_Sun</dc:creator>
      <dc:date>2020-02-21T07:24:14Z</dc:date>
    </item>
  </channel>
</rss>

