**oligou**

Member

Posted 11 months ago #

Hello,

I have this ;

(function(){

if(fieldname11=='Male')

return (5.5+(fieldname6-95)*0.1);

if(fieldname11=='Female')

return (5.5+(fieldname6-96)*0.1)

})()

It's working, but I would in any case, have a min of 5% and a max of 8%

Is it possible without extending this formula by using min and max ?

thank you !

http://wordpress.org/plugins/calculated-fields-form/

Hi,

I don't understand what you need to do with the min and max in that case. Please provide a sample or more info.

Thank you!

**oligou**

Member

Posted 11 months ago #

I don't know if min-max are suitable in this case ... just an idea

the coutcome of my fonction if, should never be min 5% or higher 8%

I know I can put another If, but too complicated ...

Is that clear now ?

Ok, this may work:

(function(){

if(fieldname11=='Male')

return max(min(5.5+(fieldname6-95)*0.1,8),5);

if(fieldname11=='Female')

return max(min(5.5+(fieldname6-96)*0.1,8),5)

})()

The use of the function is basically this one:

max(min(VALUE,8),5)

... that guarantees that if VALUE is between 5 and 8 that value will be returned. If it's higher than 8 then 8 will be returned and if it's smaller than 5 then 5 will be returned.

Hope that helps.

**vortexintercom**

Member

Posted 10 months ago #

Hi.

function(){

if(fieldname4=>50)

return prec((((fieldname2*(39.2+3))-(fieldname2*((100-fieldname4)/100)*fieldname6))/(fieldname2*fieldname4/100))*1.1082,2)

})()

It doesn't work. Where is my mistake? Thanks.

Hi,

First, the comparison symbol is >=, and not =>

Second, is not present the ( symbol at beginning of equation.

So, the correct equation format would be:

(function(){

if(fieldname4=>50)

return prec((((fieldname2*(39.2+3))-(fieldname2*((100-fieldname4)/100)*fieldname6))/(fieldname2*fieldname4/100))*1.1082,2);

})();

Hello,

How can the prec feature be added to the help you provided in this tread earlier. Here is what I'm referring to:

(function(){

if(fieldname11=='Male')

return max(min(5.5+(fieldname6-95)*0.1,8),5);

if(fieldname11=='Female')

return max(min(5.5+(fieldname6-96)*0.1,8),5)

})()

The use of the function is basically this one:

max(min(VALUE,8),5)

Where would the PREC go? Thanks

To put it more simply, how to combine prec with min or max? It doesn't seem to work the way I thought it would. thanks

Hi,

The process is simple, suppose your equation is max(fieldname1,5) to get the max number between the value of fieldname1 and five, but you need the result with two digital numbers. So the equation would be:

prec(max(fieldname1,5),2)