Number formula function

The following formula works and gives the required value. i.e. 5, 4 & 3


IF(A1=21, 5, IF(A1=20, 4, IF(A1<20, 3, "out of range")))


I want add another 4th IF. to give a value of 2 for any number over 9 but under 15

and a 5th IF to give a value of 1 for any number over 4 but under 10

any number under 5 to result in a 0 (zero)


Can anyone help?

iMac 24″, macOS 13.3

Posted on Apr 14, 2023 4:21 AM

Reply
Question marked as Top-ranking reply

Posted on Apr 14, 2023 4:56 AM

Use IFS. It's much easier than getting tangled up with nested IFS.




=IFS(A1<5,0,A1<10,1,A1<15,2,A1<20,3,A1=20,4,A1=21,5)



If this isn't exactly what you wanted or you need to add/subtract ranges you will find the function easy to edit.


More on IFS here (or via Help > Formulas and Functions Help in your menu):


IFS - Apple Support



SG



6 replies

Apr 14, 2023 10:44 PM in response to Cruso

XLOOKUP is easiest to use with an extra table, so it would be good if you have many more ranges than in your example. It is possible to use XLOOKUP in a formula without an extra table cluttering up your document, but the syntax gets complicated.


IFS is clean, succinct, straightforward, and easy to edit, and avoids the "nested ifs" tangles of the original IF function.


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Number formula function

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.