ArcGIS 123 Connect - Sum of integer Value in Repeat based on a Select One Choice

897
7
02-20-2024 08:22 AM
LindsayLewin
Occasional Contributor

I have a repeat group where the prompts the user to select one type of item found, there are many types to choose from.  Once type is selects, they need to identify the quantity - example:  1. Type: NS , Quantity : 3; 2. Type Seed, Quantity: 1; 3. Type NS, Quantity: 5

In a summary group,  I am trying to Sum the total amounts for each type selects.  So from the example above the summaries should read:

Total NS: 8   

Total Seed: 1

I've been searching all weekend on the technical forums, but have tried multiple combinations in vain.  Can anyone help with this - it seems like it should be pretty basic but I am obviously missing something.

Please help!123Connect.png123Connect_choice.png

 

 

0 Kudos
7 Replies
abureaux
MVP Frequent Contributor

sum() for a repeat

Where qty is an item in your repeat, sum(${qty}) outside the repeat will give you a total. Just be sure that both questions have the correct type (e.g., bind::type = int)

0 Kudos
abureaux
MVP Frequent Contributor

Sorry, misread.

In your repeat, you need a formula for each item in the select_one:

abureaux_0-1708448659041.png

 

Then outside the repeat, you can sum each of those calculates.

0 Kudos
LindsayLewin
Occasional Contributor

Thanks for this.  I gave this a go, and while the calculation works for the total count or time that a type is submitted, The total quantity of each still eludes me.

I need to sum the total of each quantity submitted for a single type.  When I look at the data in the App, the total FRAG should be '22' but the calculation I tried above returns '2'.

Type is a String and Quantity is an Integer, when i change the bind on type is returns an error.

 

 

 

123Connect_data.png

 

 

0 Kudos
abureaux
MVP Frequent Contributor

Does this help? Or am I missing something here?

XLSX setup:

abureaux_4-1708456638902.png

Choices tab:

abureaux_2-1708456578146.png

End result is a sum() outside the repeat for each of the select_one items that gives me the total number of times each individual item was selected.

abureaux_1-1708456572376.png

 

0 Kudos
LindsayLewin
Occasional Contributor

Hi - I really appreciate your feedback.

Each individual item has some quantity associated with it.  I need that quantity summed, not how many times the item was selected

example

Item A was chosen and a Quantity of 3 was submitted

Item B was chosen and a Quantity of 2 was submitted

Item A was chosen and a Quantity of 5 was submitted.

The summary should say Item A has a total quantity of 8 

Essentially I want to query an item choice and then sum the quantities that were submitted for those, not a count of how many times that item was selected.

I attached my form, line 28 would be the choice list that needs to be isolated and then line 33 needs to be summed from that.

 

 

0 Kudos
abureaux
MVP Frequent Contributor

Oh, opps. My bad! That can still be done though.

I'll have a look at your XLSX!

0 Kudos
abureaux
MVP Frequent Contributor

A couple things:

  • Required only has two states: <yes> and <null>. There is actually no "no" option for "required", so you don't need to specify that.
  • ${STUXO} was not formatted properly. You had an extra item attached to the end which broke the calculation:
    , sum(${qty})
  • I had to fight with line 28, ${subtype}. While it was in the document, I kept getting "Error converting XLSX". I finally realized it was because you had the bind::type set to int for it. It is a text field, so that was causing a type mismatch (I wish it would just say that!)
  • The first thing I do to surveys I am looking at (once I get them into Connect), is run Tools > Analyze survey (I highly recommend this). It noted two items which I recommend you look into:
    abureaux_0-1708467486491.png
  • And lastly, a question. Because this XLSX was working for you, I am wondering if your Connect is up to date? Current version is 3.19.104. If you don't have at least that, I'd also recommend reinstalling Connect through the Microsoft Store (MS Store version auto-updates Connect for you).

Here is what the set-up would look like for getting totals of ${qty}:

abureaux_1-1708467950057.png

abureaux_2-1708468026103.png

You just need to expand this to all available options.

Now, I need to go on and tell you about a quirk of calculates and repeats... Essentially, if you type a number into a text box within a repeat, and then immediately add a new item to that repeat, your value is ignored by calculates! This is problematic... The value will calculate properly if the end user: 1) Manually scrolls back through the repeat, 2) the user to presses "enter" after typing the value, or 3) the user clicking into another text box. But these aren't reliable options in my opinion. Luckily, you are working with numbers and not text! That make this easier...

To eliminate this issue, I recommend setting ${qty} to the numbers appearance:

abureaux_3-1708468189974.png

Basically, the numbers appearance enters the value, and then presses "Enter" for you, ensuring all calculates work as intended.

 

0 Kudos