Home » excel » Excel formula checks if evaluation is greater than and returns max value

Excel formula checks if evaluation is greater than and returns max value

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m trying to build an Excel-formula that checks if the condition part is greater than 5 without duplicating the formula. For instance if the formula returns 10, then it should return 5 (max 5). If it’s 3, then just return 3.

I could easily just extend the formula with an IF(), but then I would need to duplicate the formula to use it in my condition and if the condition is false, then I’d need to have an exact copy of the formula once again. The readability would just be twice as terrible.

I’m looking for a Max()-function, or some smart way to handle this, where it first evaluate the condition and return a max value if the condition is greater than. Any suggestions?

This is my formula:

IF(DA5746/1000>=1;DA5746/1000;1)*IF(CX5746<>"";1,1;1)*IF(M5746<>"";1,25;1)*IF(CL5746>0;IF(CL5746>1;CL5746;1+CL5746);1))

This is the formula that I’d like to avoid

IF(IF(DA5746/1000>=1;DA5746/1000;1)*IF(CX5746<>"";1,1;1)*IF(M5746<>"";1,25;1)*IF(CL5746>0;IF(CL5746>1;CL5746;1+CL5746);1))>5;5;IF(DA5746/1000>=1;DA5746/1000;1)*IF(CX5746<>"";1,1;1)*IF(M5746<>"";1,25;1)*IF(CL5746>0;IF(CL5746>1;CL5746;1+CL5746);1))) 

Psudo-solution:

IF([condition]>5;5;[reuse condition])

Edit:
I know that I can have two separate cells, where the first cell holds the long formula, and the other one just refers to this. This is not the solution I’m looking for.

How to&Answers:

The usual way is to either use a separate cell for big formula or something like:

=MIN(big_formula,5)

so in your case ( with ; separator):

=MIN(IF(DA5746/1000>=1;DA5746/1000;1)*IF(CX5746<>"";1,1;1)*IF(M5746<>"";1,25;1)*IF(CL5746>0;IF(CL5746>1;CL5746;1+CL5746);1));5)

NOTE:

The key is to avoid using IF.