Dataview, division by 0

Things I have tried

I'm trying to make a table for working on projects using the "progress bar". In general, it works, but if there are no tasks, then division by 0 occurs. How can I make a string or symbol be displayed in this case? Tried to use "||" operators and "or", but got an error.

What I’m trying to do

```dataview
table WITHOUT ID (link(file.path, alias)) as Project, length(filter(file.tasks, (t) => t.completed)) AS "yes", length(file.tasks) AS "all", "![progress](https://progress-bar.dev/" + round((length(filter(file.tasks, (t) => t.completed)) / length(file.tasks)) * 100) + "/)" AS Progress, status AS Status 
where type = "project" and status != "archive" and file.name != "project note"
SORT file.path ASC

<!-- THIS PART WON'T BE POSTED

Please describe what you're trying to accomplish so the community can better help you. Sometimes the solution you have in mind is not necessarily the best option, in which case knowing some background info can let others come up with creative solutions for your use case.

Please continue below this line. -->

maybe replacing

"![progress](https://progress-bar.dev/" + round((length(filter(file.tasks, (t) => t.completed)) / length(file.tasks)) * 100) + "/)" AS Progress

by

choice(any(file.tasks), "![progress](https://progress-bar.dev/" + round((length(filter(file.tasks, (t) => t.completed)) / length(file.tasks)) * 100) + "/)", "no tasks") AS Progress
1 Like

Works! Excellent! Thank you! :slight_smile:

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