Calculate maximum score and return the subject name

Hi @Kal_Lam and @stephanealoo,

I want to do a calculation in my form as follow:

Assume a project has got eight interventions, each intervention gets its score from different questions asked under each intervention. at the end of the form I have total score for each intervention, what i want to do is to calculate the maximum score and then return the name of that intervention i.e. Beneficiary A has been selected for Intervention one based on the highest score criteria

thank you in advance

Hello @danishjownaqibullah,

There is a max() function that you can use. If you are using calculations to create score for each part, I’m assuming you are familiar with more complex type of form building. If not, I’ll try to assist even further.


1 Like


Thank you for the response. Yes, you are very right, max() function can be used to return maximum value, but I am interested in returning the label of maximum value. i.e. for the eight interventions, i have coded as intervention one, intervention two and …so on. So if i have max(), it will return maximum value but instead i want to return the maximum value question name, i mean the header, so that i understand for what intervention the beneficiary is selected. I am familiar with jr:choice-name, but that is used with questions having options, i guess.

thank you

@danishjownaqibullah Yeah you are absolutely right. max() will only provide the value.

I’m thinking about some if functions, like if(max(X) = ${Q1}, $Q1, max(X) = ${Q2}... what do you think?

1 Like

Thank you for providing the suggestion. I used your idea to solve the issue, but instead of displaying the question, i displayed the intervention name such as ‘Intervention one’, ‘Intervention two’ and … Thank you so much for the support.


Glad to help @danishjownaqibullah :slight_smile:

1 Like