Forum Discussion
Avoiding repetition of a long formula
I have a long formula that I want to put in an if statement. If the test is true, I want to return the value of the long formula. Is there any way to avoid entering the formula twice, once for the test and once for the returned value?
Example:
if(longformula()>=0,longformula(),"Invalid negative value")
Imagine how difficult this would be to read and maintain if longformula() was actually a long, complex formula.
Are you familiar with the new LET function? If I'm understanding what you want do, that might well do it for you. One of its main purposes is to eliminate redundancy in a formula.
=LET(lofo,longformula(),IF(lofo>0),lofo(),"Invalid negative value") or something like that, would enable you to write the whole long formula only once.
2 Replies
- mathetesSilver Contributor
Are you familiar with the new LET function? If I'm understanding what you want do, that might well do it for you. One of its main purposes is to eliminate redundancy in a formula.
=LET(lofo,longformula(),IF(lofo>0),lofo(),"Invalid negative value") or something like that, would enable you to write the whole long formula only once.
- JeffGreenbergCopper ContributorExactly what I was looking for. Thanks!!!!