I would like to calculate an average of three values (document variables) and connect the average to an observation term. Can someone help?
Thanks, Jude
Where are you getting hung up? There are a few things to remember about calculating anything: First, OBS terms are always strings and second, only values can be calculated.
If something is saved as a string, like an OBS value for example, you need to use val() to turn it into a number that can be calculated. Once your calculation is complete, you need to use str() to turn it back into a string that can be saved into an OBS term.
I recently had to average the values of seven OBS terms and put the result into an eighth OBS. I don't think document variables should work that differently.
OBSNOW("YOUR_OBS", str((val(DOCUMENT.YOUR_VAR_1) +
val(DOCUMENT.YOUR_VAR_2) +
val(DOCUMENT.YOUR_VAR_3)) / 3
) //CLOSES THE str PARENS
) //CLOSES THE OBS PARENS
I'm not sure if document variables need to be forced into values, so this might need a little finessing. I hope this helps!
It worked. Thank you 🙂
Glad I could help!