Dataview basics, problem with choice function within a table

What I’m trying to do

I have recently started working with obsidian and trying to learn the basics.
I have setup a calendar and want to setup queries in table form in my homepage.

There is 1 thing I don’t seem to be able to do:

I have a table listing all events (no filters for now) and managed to add a checkmark in front of the event if completed. I also managed to list all tasks within the note in the next cell as well as a true/false statement for the completed status of the task.

However when I try to add a choice function to make it prettier (using symbols), it shows just one checkmark for the whole note.

Things I have tried

My current code which doesn’t show the completed status for all 3 tasks within the note:

TABLE WITHOUT ID file.link as Tarefas, title as Tarefa, date as Data, startTime as Hora, choice(completed = "true","☑","☐") as ✅, file.tasks.text as Etapas,  choice(file.tasks.completed = "true", "☑","☐") as ☑
FROM "2023-2024/Calendário/Tarefas"
Sort date, startTime

Code that displays correctly but “true /false” instead of the pretty symbols.

TABLE WITHOUT ID file.link as Tarefas, title as Tarefa, date as Data, startTime as Hora, choice(completed = "true","☑","☐") as ✅, file.tasks.text as Etapas,  file.tasks.completed as ☑
FROM "2023-2024/Calendário/Tarefas"
Sort date, startTime

This is my first post, so any feedback on how to properly ask questions would also be appreciated.

Thanks in advance.

Here are some queries to make your head start spinning… :slightly_smiling_face:

They illustrate how your current query are listing all tasks from any given file within the same row, and how you can split them up into single rows, or how to work with the separate tasks within each row.

- [ ] Not completed
- [/] Partially completed
- [x] Completely completed

## One row with tasks as list
```dataview
TABLE file.tasks.completed
WHERE file = this.file
```

## Multiple rows with tasks as rows
```dataview
TABLE task.text, task.completed
FROM "ForumStuff/f66/f66297"
FLATTEN file.tasks as task
```

## With emojis?
```dataview
TABLE task.text, task.completed, choice(task.completed,"☑","☐") as ✅
FROM "ForumStuff/f66/f66297"
FLATTEN file.tasks as task
```

## One row per file, but still with emojis
```dataview
TABLE map(file.tasks, (t) => choice(t.completed, "☑","☐") + " " + t.text) as  ✅
FROM "ForumStuff/f66/f66297"
```

All of the above in a single file (in the given folder, which of course can be changed to whatever you like it to), results in:

Hope this is illuminating, and helps you achieve your goal.

1 Like

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