Dataview checkboxes

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I want to display a checkbox property in the result of my dataview query and have it appear as a check or an empty checkbox rather than “true” or “false.”

Things I have tried

I have searched but not found an easy solution.

I don’t know either plugin well, but you might check if the Tasks plugin can do what you want.

Can you give a visual example of what you’re trying to do, and what code you’re using that gives you the wrong result?

The notes being queried have a property called flag, which is set as type checkbox.
This code displays “true” or “false” for flag.

table flag, item-note, join(file.tags, ", ") as tags
from #pn/hs/phn and #broken
sort item-number

I recommend using the choice() function for this.

I suggest starting with formatting the field in the TABLE clause and see if that meets your needs:

```dataview
TABLE 
	choice(Field1, "☑", "☐") as Field1,
	choice(Field2, "☑", "☐") as Field2
WHERE file.name = this.file.name
```

You could also use FLATTEN to create new fields and then refer to them in the TABLE clause. It’s more complicated, but also more flexible:

```dataview
TABLE 
	Field1Checkbox as Field1, 
	Field2Checkbox as Field2
FLATTEN choice(Field1, "☑", "☐") as Field1Checkbox
FLATTEN choice(Field2, "☑", "☐") as Field2Checkbox
WHERE file.name = this.file.name
```

Please note that the WHERE clauses in my queries are just to narrow the results; they aren’t needed for formatting the fields.

Here’s what both approaches look like in my vault:

1 Like

Thanks! Just one question: What is the ASCII codes that you used to render the checkbox symbols in the edit view?

I’m using Unicode U+2610 and U+2611.

More info:

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