Dataview query help for mapping emojis to integers in table view

I’ve been searching for hours on the forums and am still quite stuck, so hopefully I can find some help here!

What I’m trying to do

I have a number of projects that I’d like to display on my dashboard in a table for looking at a glance. I have the priority listed in the YAML of each note in the projects as a number (1-6). I’d like if possible to replace these numerical values with a coloured circle emoji to signify the urgency. Basically, replacing 1 with :red_circle:, 2 with :orange_circle:, etc.

Things I have tried

Using choice()

Currently, I have tried using a choice() function, however as the results are grouped by project, only one value (false value, X) is supplied for all of the columns (like it has been grouped itself).

TABLE rows.file.link AS Project, choice(rows.complete, "✅", "❌") AS Done, choice(rows.priority = 1, "🔴", choice(rows.priority = 2, "🟠", choice(rows.priority = 3, "🟡", choice(rows.priority = 4, "🟢", choice(rows.priority = 5, "🔵", choice(rows.priority > 5, "🟣", "X")))))) AS Priority, rows.status AS Status
FROM "Projects/Teaching"
GROUP BY regexreplace(file.folder, ".*\/([^\/]+)$", "$1") AS "Master Project"
SORT priority

The above codeblock looks like:

Using FLATTEN

I have also tried using FLATTEN to map values with emojis. I saw this on another post somewhere but unfortunately I’ve lost the tab to link the source. Using FLATTEN in this way doesn’t seem to do anything, as the original numerical values still display.

TABLE rows.file.link AS Project, choice(rows.complete, "✅", "❌") AS Done, rows.priority AS Priority, rows.status AS Status
FROM "Projects/Teaching"
FLATTEN { "1": "🔴", "2": "🟠", "3": "🟡", "4": "🟢", "5": "🔵", "6": "🟣"}[Priority] as PriorityIcon
GROUP BY regexreplace(file.folder, ".*\/([^\/]+)$", "$1") AS "Master Project"

The above codeblock looks like:

Any help would be greatly appreciated, thank you!

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