Skip to main content
Nintex Community Menu Bar
Solved

Calculation based on Choice


Forum|alt.badge.img+2

So I have a new calculation that I need to display in Nintex Forms. I have about 15 choice questions, each has the same 4 options. Satisfactory, Needs Improvement, Unsatisfactory and N/A. I want to add up the Satisfactory selections and display them as a percentage. For example, If I had 10 questions, and 5 were selected as Satisfactory the percent displayed would be 50%. 

How do I create that variable? 

Best answer by bamaeric

Below is how you can do this with two form variables. You could probably do this with just one variable, but I did not want to overcomplicate it.

Form Variable 1:

  • Name = intChoicesSatCount
  • Type = Integer
  • Formula = 
    sum(ifElse(contains([Form].[Choice1],"Satisfactory"),1,0),ifElse(contains([Form].[Choice2],"Satisfactory"),1,0),ifElse(contains([Form].[Choice3],"Satisfactory"),1,0),ifElse(contains([Form].[Choice4],"Satisfactory"),1,0),...)
  • Formula Note: Just keep adding the ifElse function syntax for each Choice field (15 in total).

Form Variable 2:

  • Name = decSatPercent
  • Type = Decimal
  • Formula = round(([Form].[intChoicesSatCount]/15)*100,0)
  • Formula Note: I had the round function round to 0 decimal places.

If you would like, you can add a Label control to the form and insert the decSatPercent form variable (along with a fixed % sign) to display the percentage.

 

 

View original
Translate
Did this topic help you find an answer to your question?

8 replies

bamaeric
Forum|alt.badge.img+13
  • Apprentice
  • 463 replies
  • June 3, 2024

Which forms designer (Classic, Responsive, or New Responsive) are you using? 

Translate

Forum|alt.badge.img+2
  • Author
  • Rookie
  • 7 replies
  • June 3, 2024

New Responsive 

Translate

bamaeric
Forum|alt.badge.img+13
  • Apprentice
  • 463 replies
  • Answer
  • June 3, 2024

Below is how you can do this with two form variables. You could probably do this with just one variable, but I did not want to overcomplicate it.

Form Variable 1:

  • Name = intChoicesSatCount
  • Type = Integer
  • Formula = 
    sum(ifElse(contains([Form].[Choice1],"Satisfactory"),1,0),ifElse(contains([Form].[Choice2],"Satisfactory"),1,0),ifElse(contains([Form].[Choice3],"Satisfactory"),1,0),ifElse(contains([Form].[Choice4],"Satisfactory"),1,0),...)
  • Formula Note: Just keep adding the ifElse function syntax for each Choice field (15 in total).

Form Variable 2:

  • Name = decSatPercent
  • Type = Decimal
  • Formula = round(([Form].[intChoicesSatCount]/15)*100,0)
  • Formula Note: I had the round function round to 0 decimal places.

If you would like, you can add a Label control to the form and insert the decSatPercent form variable (along with a fixed % sign) to display the percentage.

 

 

Translate

Forum|alt.badge.img+2
  • Author
  • Rookie
  • 7 replies
  • June 4, 2024

That worked great! Thank you. One last thing, I understand how to display the number in a label, how do I put it into a field that will be saved to the Sharepoint list? 

Translate

bamaeric
Forum|alt.badge.img+13
  • Apprentice
  • 463 replies
  • June 4, 2024

Glad I could help. Below are steps to save the percentage in a list column.

  1. Create a new column in the list of type Number (if you have not already). I named mine SatPercentage.
  2. Add a Number control to the form with these settings:
    - Title = SatPercent (or whatever you would like to name it)
    - Connected to: SatPercentage (this is where you connect the form field value to the list column)
    - Numeric type = Decimal
    - Number of decimal places: Automatic
    - Visible = No (you can set this to Yes for testing)
    - Read-only = Yes
  3. Create a form rule (see image below):
    - Name = Set SatPercent Field
    - IF decSatPercent Greater than or equals 0
      THEN SatPercent Value decSatPercent
      ELSE SatPercent Value 0

 

Translate

Forum|alt.badge.img+2
  • Author
  • Rookie
  • 7 replies
  • June 4, 2024

Thank you! 

Translate

Forum|alt.badge.img+2
  • Author
  • Rookie
  • 7 replies
  • June 19, 2024

Quick Question, Now they are asking for it to count N/A as well. How do I need to tweak the formula to include “Satisfactory and N/A”? 

Translate

bamaeric
Forum|alt.badge.img+13
  • Apprentice
  • 463 replies
  • June 19, 2024

What I would to avoid the first formula getting too complicated is create a second form variable of type integer to sum up the “N/A” choices. All you would need to do is copy the formula for the “Satisfactory” variable, then replace the “Satisfactory” parameter with the “N/A” choice. This formula would look like this:

sum(ifElse(contains([Form].[Choice1],"N/A"),1,0),ifElse(contains([Form].[Choice2],"N/A"),1,0),ifElse(contains([Form].[Choice3],"N/A"),1,0),ifElse(contains([Form].[Choice4],"N/A"),1,0),...)

Next create another integer form variable to sum up the other two choices variables. That formula would look like this:

[Form].[intChoicesSatCount] + [Form].[intChoicesNACount]

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings