Hello.
I've got a survey where I'm trying to calculate a numerical risk score and correlate that score to a risk level, e.g. low, moderate & high based on varying scores. Currently I'm able to calculate the score and use relevance to display the risk level on the survey, but I need to use the risk level (low, moderate, high) in reporting and Operations Dashboard. Is there a way to automatically select an answer to a select one risk level question based on a calculation? Or any other ways of accomplishing this?
Thanks!
Dave
You could create a text field and use nested "if" statements to calculate the value based on the score.
For example:
if(${riskScore} < 100, "Low", if(${riskScore} < 300, "Moderate", if(${riskScore} >= 300, "High", "None")))
This calculation would set the text value to be "Low" if riskScore is <100, "Moderate" if riskScore is >= 100 and < 300, "High" if riskScore is >= 300, and "None" otherwise (if riskScore is blank, for example).
This thread has more discussion about nested "if" statements:
Thanks Stephen!
I had tried that and tried it again after your recommendation. The error I keep getting says "...XPath evaluation: cannot handle function 'if' requires 3 arguments. Only 2 provided.
Any ideas?
That error suggests that one of the three elements of an "if" statement is missing (test condition, return if true, return if false). With how complicated nested ifs can get, it could just be an issue of a missing comma somewhere in the statement.
I finally figured it out! Here's what I ended up with:
if((${total}>0 and ${total}<=12),"Unlikely",if((${total}>=13 and ${total}<=35),"Low",if((${total}>=36 and ${total}<=45),"Moderate",if(${total}>=46,"High",null)))) |
Thanks again for your help Stephen!