How toi create formula using IFS and AND

%3CLINGO-SUB%20id%3D%22lingo-sub-1656989%22%20slang%3D%22en-US%22%3EHow%20toi%20create%20formula%20using%20IFS%20and%20AND%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1656989%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20create%20a%20formula%20using%20IFS%20to%20check%20three%20possible%20outcomes%3A%3C%2FP%3E%3CP%3Evalue%26lt%3B5000%20-%20return%20RM%3C%2FP%3E%3CP%3E5000%3CVALUE%3E%26lt%3B30000%20-%20return%20VPO%3C%2FVALUE%3E%3C%2FP%3E%3CP%3Evalue%26lt%3B30000%20-%20return%20IPC%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20managed%20to%20get%20the%20true%20value%20return%20for%20the%20first%20and%20the%20last%20logical%20test%2C%20while%20the%20middle%20where%20it%20checks%20for%20value%20above%20and%20below%20returns%20N%2FA%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETried%20adding%20the%20use%20of%20AND%20in%20the%20middle%20but%20still%20returns%20N%2FA%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyone%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1656989%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1657102%22%20slang%3D%22en-US%22%3ERe%3A%20How%20toi%20create%20formula%20using%20IFS%20and%20AND%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1657102%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F790242%22%20target%3D%22_blank%22%3E%40kkrakenes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet's%20say%20the%20value%20is%20in%20A2.%20The%20formula%20(in%20another%20cell)%20could%20be%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIFS(A2%26lt%3B5000%2C%22RM%22%2CA2%26lt%3B30000%2C%22VPO%22%2CA2%26gt%3B%3D30000%2C%22IPC%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eor%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIF(A2%26lt%3B5000%2C%22RM%22%2CIF(A2%26lt%3B30000%2C%22VPO%22%2C%22IPC%22))%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eor%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DLOOKUP(A2%2C%7B0%2C5000%2C30000%7D%2C%7B%22RM%22%2C%22VPO%22%2C%22IPC%22%7D)%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am trying to create a formula using IFS to check three possible outcomes:

value<5000 - return RM

5000<value<30000 - return VPO

value<30000 - return IPC

 

I have managed to get the true value return for the first and the last logical test, while the middle where it checks for value above and below returns N/A 

 

Tried adding the use of AND in the middle but still returns N/A

 

Anyone?

 

3 Replies

@kkrakenes 

Let's say the value is in A2. The formula (in another cell) could be

 

=IFS(A2<5000,"RM",A2<30000,"VPO",A2>=30000,"IPC")

 

or

 

=IF(A2<5000,"RM",IF(A2<30000,"VPO","IPC"))

 

or

 

=LOOKUP(A2,{0,5000,30000},{"RM","VPO","IPC"})

@kkrakenes , 

This is a "Nested If" problem. First, let us solve that:

 

IF (value<5000, "RM",  IF (value<30000, "VPO",  "IPC"))

 

Nested IF statements are notoriously hard to maintain and are prone to error.

 

An easier to maintain and less error prone approach is to leverage Excel's tables like the one below. I called this "tblCodes".

tblCodestblCodes

tblCodes is fully dynamic so if we add codes or change values, we can make the changes to the table and leave our formula unchanged. The formula is then:

 

=VLOOKUP(<value>,tblCodes,2,TRUE)

 

Where <value> is the cell address or name holding 0, 5000, or 30000.  See attached

@Craig Hatmaker 

 

Thanks for the tip.

 

After playing around a little longer I found a solution;

 

=IFS(S22<=5000,"RM",AND(S22>5000,S22<=30000),"VPO",30000<S22,"IPC")