conditional: display the field with the higher result

[ad_1]

Hello @stefaninthailand

You have many options to use conditionals in the equations.

You can use the “IF” operation:

IF(fieldname1<fieldname2, fieldname2, fieldname1)

You can use the ternary javascript operator:

(fieldname1<fieldname2) ? fieldname2 : fieldname1

You can use the “if” conditional statement in javascript (javascript is a case-sensitive language, please, do not confuse it with the “IF” operation), and function structure:

(function(){
if(fieldname1<fieldname2) return fieldname2;
return fieldname1;
})()

However, in this specific case, you don’t need conditionals, only use the “MAX” operation:

MAX(fieldname1,fieldname2);

Note that fieldname1 and fieldname2 can be replaced by their respective formulas instead of using multiple calculated fields.

For example, if the equation in the fieldname1 is fieldname3+fieldname4, and the equation of fieldname2 is fieldname5+fieldname6 (these are hypothetical equations and fields’ names, selected only to describe the process), instead of using two calculated fields for fieldname1 and fieldname2, you can implement everything in a unique calculated field:

MAX(fieldname3+fieldname4, fieldname5+fieldname6)

Best regards.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer