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.
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.
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?
Glad I could help. Below are steps to save the percentage in a list column.
Create a new column in the list of type Number (if you have not already). I named mine SatPercentage.
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
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
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: