Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

A function to automate the classification of value ranges

How could I classify this data according to these criteria?

A B
1 Af Class
2 73.73
3 68.10
4 39.69
5 50.51
6 18.23
Class Range
Class 1 Af < 21 or 68 <= Af
Class 2 21 <= Af < 42 or 55 <= Af < 68
Class 3 42 <= Af < 55

I’ve tried using IF OR but without success.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The criteria can be simplified:

if 42 <= Af < 55:
    Class 3
else if 21 <= Af < 68:
    Class 2
else:
    Class 1

This can be expressed in a formula, formatted to match the layout of the pseudocode:

=IF(AND(42 <= @A:A, @A:A < 55),
    "Class 3",
 IF(AND(21 <= @A:A, @A:A < 68),
    "Class 2",
    "Class 1"
))

Or in a single line:

=IF(AND(42 <= @A:A, @A:A < 55),"Class 3", IF(AND(21 <= @A:A, @A:A < 68), "Class 2", "Class 1"))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading