<?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 Calculate default value when only 1 option is available in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/calculate-default-value-when-only-1-option-is/m-p/1550344#M59723</link>
    <description>&lt;P&gt;Hi Team. I'm trying to make my form a little smarter. I have 2 fields: Type and Subtype.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some hazard types have only 1 matching Subtype, whereas others have multiple to pick from.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want my subtype field to automatically fill out the only available value when there is only 1 value to pick from, but be blank when multiple options are available. Is this possible? I tried this with Copilot but failed as it tried using Count which I believe is for repeats only, then tried another approach but that also failed (see Copilot outputs below).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Method 1:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Prepare Your CSV File&lt;/STRONG&gt;: Ensure your CSV file is structured with columns for the key and the values you want to pull. For example:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;key,value
A1,Option1
A2,Option2
A2,Option3&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Load the CSV File&lt;/STRONG&gt;: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pulldata&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function to load the values from the CSV file based on the answer in Field A.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Create a Calculation Field&lt;/STRONG&gt;: Add a calculation field to determine the number of options available for Field B based on the answer in Field A. &lt;EM&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;lt;- this is the step that threw an error in Survey123 Connect&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;type          name            label               calculation
calculate     options_count   Options Count       count(pulldata('csv_file', 'value', 'key', ${field_a}))&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Set Up Field B&lt;/STRONG&gt;: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;relevant&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column to control the visibility of Field B and the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;default&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column to set its default value.&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;type          name            label               relevant                       default
select_one    field_b         Field B             ${options_count} &amp;gt; 0           if(${options_count} = 1, pulldata('csv_file', 'value', 'key', ${field_a}), '')&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Filter Choices for Field B&lt;/STRONG&gt;: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;choice_filter&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column to filter the choices for Field B based on the answer in Field A.&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;type          name            label               choice_filter
select_one    field_b         Field B             key = ${field_a}&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In this setup:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;options_count&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field calculates the number of options available for Field B.&lt;/LI&gt;&lt;LI&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;relevant&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column ensures Field B is only shown if there are options available.&lt;/LI&gt;&lt;LI&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;default&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column sets the default value of Field B to the single option if only one is available, otherwise it remains blank.&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-questions/how-do-i-create-a-list-of-choices-based-on/td-p/839217" target="_blank" rel="noopener"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;choice_filter&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column filters the choices for Field B based on the answer in Field A&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Method 2:&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Prepare Your CSV File&lt;/STRONG&gt;: Ensure your CSV file is structured properly with columns for the key and values.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pulldata&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to Retrieve Values&lt;/STRONG&gt;: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pulldata&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function to fetch the values from the CSV file. &lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;lt;- this step failed to return all the values, just the first value, thus never generating a reliable count&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Calculate the Number of Matching Choices&lt;/STRONG&gt;: Use a calculation field to determine the number of matching choices.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Set Default Value Conditionally&lt;/STRONG&gt;:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;type          name            label               calculation
calculate     matching_values Matching Values     pulldata('csv_file', 'value', 'key', ${field_a})
calculate     count_values    Count Values        if(${matching_values} != '', count-selected(${matching_values}), 0)
text          field_b         Field B             if(${count_values} = 1, ${matching_values}, '')&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In this setup:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;matching_values&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;retrieves the values from the CSV file based on the answer in Field A.&lt;/LI&gt;&lt;LI&gt;count_values&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;calculates the number of matching values.&lt;/LI&gt;&lt;LI&gt;field_b&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sets the default value to the single matching value if only one is found, otherwise it remains blank.&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Mon, 21 Oct 2024 06:28:31 GMT</pubDate>
    <dc:creator>LindsayRaabe_FPCWA</dc:creator>
    <dc:date>2024-10-21T06:28:31Z</dc:date>
    <item>
      <title>Calculate default value when only 1 option is available</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/calculate-default-value-when-only-1-option-is/m-p/1550344#M59723</link>
      <description>&lt;P&gt;Hi Team. I'm trying to make my form a little smarter. I have 2 fields: Type and Subtype.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some hazard types have only 1 matching Subtype, whereas others have multiple to pick from.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want my subtype field to automatically fill out the only available value when there is only 1 value to pick from, but be blank when multiple options are available. Is this possible? I tried this with Copilot but failed as it tried using Count which I believe is for repeats only, then tried another approach but that also failed (see Copilot outputs below).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Method 1:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Prepare Your CSV File&lt;/STRONG&gt;: Ensure your CSV file is structured with columns for the key and the values you want to pull. For example:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;key,value
A1,Option1
A2,Option2
A2,Option3&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Load the CSV File&lt;/STRONG&gt;: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pulldata&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function to load the values from the CSV file based on the answer in Field A.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Create a Calculation Field&lt;/STRONG&gt;: Add a calculation field to determine the number of options available for Field B based on the answer in Field A. &lt;EM&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;lt;- this is the step that threw an error in Survey123 Connect&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;type          name            label               calculation
calculate     options_count   Options Count       count(pulldata('csv_file', 'value', 'key', ${field_a}))&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Set Up Field B&lt;/STRONG&gt;: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;relevant&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column to control the visibility of Field B and the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;default&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column to set its default value.&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;type          name            label               relevant                       default
select_one    field_b         Field B             ${options_count} &amp;gt; 0           if(${options_count} = 1, pulldata('csv_file', 'value', 'key', ${field_a}), '')&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Filter Choices for Field B&lt;/STRONG&gt;: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;choice_filter&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column to filter the choices for Field B based on the answer in Field A.&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;type          name            label               choice_filter
select_one    field_b         Field B             key = ${field_a}&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In this setup:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;options_count&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field calculates the number of options available for Field B.&lt;/LI&gt;&lt;LI&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;relevant&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column ensures Field B is only shown if there are options available.&lt;/LI&gt;&lt;LI&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;default&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column sets the default value of Field B to the single option if only one is available, otherwise it remains blank.&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-questions/how-do-i-create-a-list-of-choices-based-on/td-p/839217" target="_blank" rel="noopener"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;choice_filter&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column filters the choices for Field B based on the answer in Field A&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Method 2:&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Prepare Your CSV File&lt;/STRONG&gt;: Ensure your CSV file is structured properly with columns for the key and values.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pulldata&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to Retrieve Values&lt;/STRONG&gt;: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pulldata&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function to fetch the values from the CSV file. &lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;lt;- this step failed to return all the values, just the first value, thus never generating a reliable count&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Calculate the Number of Matching Choices&lt;/STRONG&gt;: Use a calculation field to determine the number of matching choices.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Set Default Value Conditionally&lt;/STRONG&gt;:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;type          name            label               calculation
calculate     matching_values Matching Values     pulldata('csv_file', 'value', 'key', ${field_a})
calculate     count_values    Count Values        if(${matching_values} != '', count-selected(${matching_values}), 0)
text          field_b         Field B             if(${count_values} = 1, ${matching_values}, '')&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In this setup:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;matching_values&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;retrieves the values from the CSV file based on the answer in Field A.&lt;/LI&gt;&lt;LI&gt;count_values&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;calculates the number of matching values.&lt;/LI&gt;&lt;LI&gt;field_b&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sets the default value to the single matching value if only one is found, otherwise it remains blank.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Mon, 21 Oct 2024 06:28:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/calculate-default-value-when-only-1-option-is/m-p/1550344#M59723</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2024-10-21T06:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate default value when only 1 option is available</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/calculate-default-value-when-only-1-option-is/m-p/1550370#M59725</link>
      <description>&lt;P&gt;I'd separate this into two questions. One that's calculated and one that provides choices.&lt;/P&gt;&lt;P&gt;Use relevancy to show the question based on the number of choices available.&lt;/P&gt;&lt;P&gt;Now how you get this, I'd look at:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Creating a CSV file for pulldata against type and one/many values, prepared and update alongside the original CSV&lt;/LI&gt;&lt;LI&gt;JavaScript. You (Copilot) could write a function to count the values matching Type and then apply the outcome to the relevant filter.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Otherwise no it's not possible as far as I'm aware and the Survey123 team has it in their backlog. I personally try to avoid overly complicated applications of formulas to circumvent the lack of available functionality as more often then not it bites you.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-questions/default-value-from-cascading-select/td-p/880095" target="_blank"&gt;https://community.esri.com/t5/arcgis-survey123-questions/default-value-from-cascading-select/td-p/880095&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 09:07:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/calculate-default-value-when-only-1-option-is/m-p/1550370#M59725</guid>
      <dc:creator>ChristopherCounsell</dc:creator>
      <dc:date>2024-10-21T09:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate default value when only 1 option is available</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/calculate-default-value-when-only-1-option-is/m-p/1550693#M59736</link>
      <description>Thanks for the suggestions, but I think I'm taking your other approach and avoiding it too. The user will just have to do the extra 1 or 2 taps/clicks on this case. At least the majority of scenarios only have 1 choice and it's not a massive form so not a big case for taps minimisation.&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Oct 2024 22:18:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/calculate-default-value-when-only-1-option-is/m-p/1550693#M59736</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2024-10-21T22:18:50Z</dc:date>
    </item>
  </channel>
</rss>

