Forum

Notifications
Clear all

IFS or Nested IF

9 Posts
5 Users
0 Reactions
159 Views
(@benjamip)
Posts: 89
Estimable Member
Topic starter
 

Hi

I'm trying to find a formula that gives me the following tests & values if true.

I have tried IFS and nested IF with AND, but just do not have the skill level to accomplish required result

 

Need a formula that fist looks at Occupancy % (cell M5) and then:

If below 40% calculates M6*A3

If between 40% & 49% calculates M4*B3

If between 50% & 59% calculates M4*C3

If greater than 60% calculates M4*D3

 

Thanks

Paul

 
Posted : 05/05/2020 12:39 pm
(@purfleet)
Posts: 412
Reputable Member
 

It all depends if you have office 365 or an older version of excel.

On 2016 or older you would need nested IF(s) with and(s)

=IF(M5<0.4,M6*A3,IF(AND(M5>=0.4,M5<=0.49),M4*B3,IF(AND(M5>=0.4,M5<=0.49),M4*B3,IF(AND(M5>=0.5,M5<=0.59),M4*C3,IF(M5>=0.6,M4*D3)))))

You could also (possibly) use a vlookup to get the number with an approximate match and then do a simpler if

=VLOOKUP(M5,$A$7:$B$10,2,TRUE)

See attached

Purfleet

 
Posted : 05/05/2020 3:48 pm
Anders Sehlstedt
(@sehlsan)
Posts: 970
Prominent Member
 

Hello,

Using IFS function is almost as nested IF’s.

=IFS(M5<0.4,M6*A3,AND(M5>=0.4,M5<=0.49),M4*B3,AND(M5>=0.5,M5<=0.59),M4*C3,M5>=0.6,M4*D3)

Br,
Anders

 
Posted : 05/05/2020 4:37 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Paul,

Because the IF statement will only evaluate until it finds a True condition you can use this, leaving out the AND's, by making your first test for the largest value and then working down 

=IF($M$5>0.6,$M$4*$D$3,IF($M$5>0.5,$M$4*$C$3,IF($M$5>0.4,$M$4*$B$3,$M$4*$A$3)))

Regards

Phil

 
Posted : 05/05/2020 6:59 pm
Anders Sehlstedt
(@sehlsan)
Posts: 970
Prominent Member
 

Thanks for the tip Phil! I am now just wondering how on earth I have missed such simple fact during the years I have used Excel. There is always something to learn. The same implies also to IFS, so a revised formula would be

=IFS(M5>=0.6,M4*D3,M5>=0.5,M4*C3,M5>=0.4,M4*B3,M5<0.4,M6*A3)

 
Posted : 05/05/2020 8:51 pm
(@purfleet)
Posts: 412
Reputable Member
 

Mind blown

Such a simple, obvious concept yet i completely missed it

Excellent work Phil 

 
Posted : 06/05/2020 3:13 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Between us we came up with 5 solutions.  Pretty good. 🙂

 
Posted : 06/05/2020 3:31 am
(@debaser)
Posts: 837
Member Moderator
 

Just a small note that nested IF is more efficient since IFS evaluates everything passed to it, no matter which order you do it in.

 
Posted : 06/05/2020 4:58 am
(@benjamip)
Posts: 89
Estimable Member
Topic starter
 

Many thanks for the help, I have learnt so much from the replies

A big shout out to Philip, Purfleet, Anders & VelouriaSmileSmileSmile

 
Posted : 06/05/2020 7:29 am
Share: