How do I get the sum of boxes selected by adding the counts of the checked boxes in all 3 checkbox custom fields?

Issue #806 resolved
Joseph Pursel created an issue

I have 3 checkbox custom fields each containing 4 choices, As below: This is conditional on at least 1 of the 12 checkboxes being checked. If none are checked, I want to have the user make at least 1 selection? (I see how to do this with a multi-select custom field but I do not see how to count checkboxes in a custom field in the JWT documentation or issues.) a. Field 1 i. A ii. B iii. C iv. D b. Field 2 i. P ii. Q iii. R iv. S c. Field 3 i. W ii. X iii. Y iv. Z The user can select 1, 2, 3 or all 4 boxes in each Custom Field. How do I get the sum of boxes selected by adding the counts of the checked boxes in all 3 checkbox custom fields? I want to store the count in a custom field named “Checkbox Count”. I presume this is a Number type custom field.

Thank you, Joe Pursel

Comments (6)

  1. Fidel Castro Armario repo owner

    Hi @amazonadmin,

    You can create a "Calculated Number Field" called "Checkbox Count" with the following formula:

    numberOfSelectedItems(%{aaaaa}) + numberOfSelectedItems(%{bbbbb}) + numberOfSelectedItems(%{ccccc})
    

    replacing aaaaa, bbbbb and ccccc with field codes for each of the checkboxes custom fields.

  2. Joseph Pursel reporter

    Hi Fidel,

    Thank you for your prompt reply! Based on your response, I don't need to assign this count to the Checkbox Count using a post function as the custom field will always be the sum of the boxes checked. Is this true? Also, if a checkboxes are selected in the custom field, will the field be represented as (aaaaa,0) = Yes or 1 if checked, (aaaaa,1) = No or 0 if not checked?

    Later in the transition, I will need to apply a value to each item. Then, using my example in my original request, (aaaaa,0) has a value = 5. (aaaaa,1) has a value of 10 and (aaaaa,2) has a value of 15. If (ddddd,0) and if (ddddd,2) are selected and (ddddd,1) is not selected, would I use in a Calculated Number Field to store the result of 20? I will need to have this number available later in the transition.

    Best, Joe

  3. Fidel Castro Armario repo owner

    Hi @amazonadmin,

    Calculated Number Field always shows the updated result of the formula used for calculating the value.

    Sorry, I don't understand your other requirements. I don't understand what you mean by:

    Also, if a checkboxes are selected in the custom field, will the field be represented as (aaaaa,0) = Yes or 1 if checked, (aaaaa,1) = No or 0 if not checked? Later in the transition, I will need to apply a value to each item. Then, using my example in my original request, (aaaaa,0) has a value = 5. (aaaaa,1) has a value of 10 and (aaaaa,2) has a value of 15. If (ddddd,0) and if (ddddd,2) are selected and (ddddd,1) is not selected, would I use in a Calculated Number Field to store the result of 20? I will need to have this number available later in the transition.

    Can you, please, try to explain it using other words?

  4. Joseph Pursel reporter

    Hi Fidel,

    I am sorry for the confusion. Here is the question stated differently.

    I have a list of items in a checkbox custom field named "Scope". There are 4 items (checkboxes) in this field. Each item has a value representing the size of the items scope. For example: Item 1 value = 5 Item 2 value = 10 Item 3 value = 15 Item 4 value = 20

    Now, lets say the user selected Items 1 and 4 which will provide the sum of the values selected = 5 + 20 = 25. I want to store the sum of the checked items, which is 25, in a custom field named "Priority Rank". How do I do this?

    Thank you, Joe

  5. Fidel Castro Armario repo owner

    You can use the following math formula:

    (%{nnnnn} ~ "Item 1" ? 5 : 0) +
    (%{nnnnn} ~ "Item 2" ? 10 : 0) +
    (%{nnnnn} ~ "Item 3" ? 15 : 0) +
    (%{nnnnn} ~ "Item 4" ? 20 : 0)
    

    replacing nnnnn with field code for Scope custom field.

  6. Log in to comment