# calculate variables to get result from a third variable

New Here ,
Jan 29, 2021 Jan 29, 2021

Copied

I have Acrobat Pro 2020 and finishing with creating a form, but, of course, I am running into a problem 🙂

I have 4 variables: Gender, Conclusion1, Conclusion2, and Percentage

Gender results in a 1 for female and 2 for male

Conclusion1 has already been calculated based on female-related percentage scores derived from total items selected as yes

Conclusion2 has already been calculated based on male-related percentage scores derived from total items selected as yes

I am trying to write code for the Percentage variable that will basically say "if gender = 1, then display the results from the variable Conclusion1; and f gender = 2, then display the results from the variable Conclusion2

Ideas on writing this code?

TOPICS
How to

Views

42

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
5 Replies 5
Most Valuable Participant ,
Jan 29, 2021 Jan 29, 2021

Copied

You can use this code as the custom calculation script of the percentage score field:

var gender = this.getField("Gender").valueAsString;

if (gender=="1" ) event.value = this.getField("Conclusion1").valueAsString;

else if (gender=="2" ) event.value = this.getField("Conclusion2").valueAsString;

else event.value = "";

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jan 29, 2021 Jan 29, 2021

Copied

This works great; however, as I change the number of yes responses, Conclusion1 and Conclusion2 update correctly, but the Percentage field changes to other weird numbers?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jan 29, 2021 Jan 29, 2021

Copied

This works great; however, as I change the number of yes responses, Conclusion1 and Conclusion2 update correctly, but the Percentage field changes to other weird numbers?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jan 29, 2021 Jan 29, 2021

Copied

As I responded above, this works great; however, as I change the number of yes responses, Conclusion1 and Conclusion2 update correctly, but the Percentage field changes to other weird numbers? When I select a different gender and then go back to the same gender, everything updates correctly. That is also the case if I just selct the other gender. So this Percentage does not update as I add the number of yes responses --- unless I re-enter the Gender?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 29, 2021 Jan 29, 2021

Copied

LATEST

Change the field calculation order.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources