Quote:
Originally Posted by BetterRed
|

Thanks for the link. I did have a look there and it did help somewhat.
I have almost got this working now, though I still have a couple of issues to iron out, and any help you might offer will be appreciated.
First, in order to ensure that I do not attempt the division if either
#words or
#pages have null or zero values, I first created a temporary custom column called
#ready, which has the following template:
Code:
{:'and(field('#words'), strcmp(field('#words'), "", "", "", cmp(field('#words'), 0, "", "", field('#words'))), field('#pages'), strcmp(field('#pages'), "", "", "", cmp(field('#pages'), 0, "", "", field('#pages'))))'}
This seems to work perfectly, returning a "1" only when the division makes sense, else it is empty.
Using
#ready as a base, I then created another custom field to carry out the division and called it
#awp (average words per page). This field has the template:
Code:
{:'test(and(field('#words'), strcmp(field('#words'), "", "", "", cmp(field('#words'), 0, "", "", field('#words'))), field('#pages'), strcmp(field('#pages'), "", "", "", cmp(field('#pages'), 0, "", "", field('#pages')))), divide(field('#words'), field('#pages')), "")'}
Apart from one use case, this works, returning a floating point value. I need to work out how to round the returned value to a whole number, though.
The only time it doesn't work is when both
#words and
#pages contain null values. In this case, I get the following error message:
Code:
EXCEPTION: float division by zero
Can you help solve these issues?