Dataview how to compare numbers to get a result

I am making a dataview table to track my sleep. My app gives a sleep score with a qualifier such as good or poor. Each qualifier has a number range. I would like to be able to make a column that gives me the qualifier next to the score. This is what I have so far, but I keep getting a parsing error. Can anyone help me figure out what I am doing wrong?

Morning Startup

Startup Stats

Sleep Start Time:: 2:54 AM
Out of Bed:: 9:59 AM
Total Sleep:: 6:34
Awake Time:: :31
REM Sleep:: 1:34
Light Sleep:: 3:52
Deep Sleep:: 1:8
Sleep Score:: 81

TABLE WITHOUT ID
	sleep-start-time AS "Sleep Start Time",
	awake-time AS "Awake Time",
	total-sleep AS "Total Sleep",
	out-of-bed AS "Out of Bed",
	sleep-score AS "Sleep #"
	choice((sleep-score < 100 or <= 90, "🟡 Excellent", choice((sleep-score < 89 or >= 80, "🟢 Good", choice((sleep-score < 60 or  >= 79, "🟠 Fair", choice((sleep-score < 60,  "🔴Poor"))) AS "Sleep Score"
	where sleep-score
FROM #iso2022-03-01

Two points:

  1. If FROM it needs to be placed before any filter command, i.e., before any where
  2. Your “nested” choice() functions are a mess… :slight_smile:

Try this:

```dataview
TABLE WITHOUT ID
  sleep-start-time AS "Sleep Start Time",
  awake-time AS "Awake Time",
  total-sleep AS "Total Sleep",
  out-of-bed AS "Out of Bed",
  sleep-score AS "Sleep #",
  choice(sleep-score >= 90, "🟡 Excellent", choice(sleep-score < 90 AND sleep-score >= 80, "🟢 Good", choice(sleep-score < 80 AND sleep-score >= 60, "🟠 Fair", choice(sleep-score < 60, "🔴Poor", "error")))) AS "Sleep Score"
FROM #iso2022-03-01
WHERE sleep-score
```

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.