if-statementgoogle-sheetsmatchvlookupnested-if

How to group range of numbers into categories of number ranges in Google Sheets


I have a column of the range of body mass index numbers (BMI) that I want to automatically group into categories or buckets in another column. It looks like this:

colA    colB

BMI     BMI Grouping
23.11   BMI ≥ 18.5 - 24.9
22.66   BMI ≥ 18.5 - 24.9
33.55   BMI ≥ 30 - 34.9
40.12   BMI ≥ 35

I have 5 'BMI Grouping' categories that I want to categorise the range of BMI into:

Please teach me the formula or code needed for Google Sheets.


Solution

  • you can use IFS with a combo of ARRAYFORMULA like:

    =IFERROR(ARRAYFORMULA(
     IFS(A2:A>=35,   "BMI ≥ 35",
         A2:A>=30,   "BMI ≥ 30 - 34.9",
         A2:A>=25,   "BMI ≥ 25 - 29.9", 
         A2:A>=18.5, "BMI ≥ 18.5 - 24.9",
         A2:A>=1,    "BMI < 18.5")), )