File 2 test: this file contains 2 properties (current, total)
The goal is to make a table with progress bars using tasks count if there are tasks, or current/total if there is current and total property.
TABLE WITHOUT ID
file.link as "Subproject",
"<progress value='" + Progress + "' max='100'></progress> "+ floor(Progress)+"%" AS "Progress", Progress as check
WHERE link = this.file.name
FLATTEN choice(current,number(current/total*100),(length(filter(file.tasks.completed, (t) => t = true))/length(file.tasks.total)*100)) as "Progress"
as you see only one file appears, but if i remove the “*100” then:
TABLE WITHOUT ID
file.link as "Subproject",
"<progress value='" + Progress + "' max='100'></progress> "+ floor(Progress)+"%" AS "Progress", Progress as check
WHERE link = this.file.name
FLATTEN choice(current,number(current/total),(length(filter(file.tasks.completed, (t) => t = true))/length(file.tasks.total)*100)) as "Progress"
So I don’t know what “choice” does, and I don’t know your inputs, so I’m not entirely sure.
I just wonder if it’s an order of operations. You might need number((current/total)*100) so you are multiplying current/total by 100, instead of dividing current by total*100.
Because a quick google tells me in Javascript, multiplication comes first. And I assume Dataview is the same. And from my memory of math class, multiplication and division are the same priority, so it’s best to bracket.
And I have no idea about integer math vs. float math in Dataview, but if I was in Python, I would be using 100.0 instead of 100, to make sure I’m doing proper float math and not rounding accidentally.
TABLE WITHOUT ID category as "Category",
file.link as "Project",
"<progress value='" + Progress + "' max='100'></progress> "+ floor(Progress)+"%" AS "Progress"
WHERE link = this.file.name
FLATTEN choice(total and current,number(current/total),(length(filter(file.tasks.completed, (t) => t = true))/length(file.tasks.total)*100)) as "Number"
FLATTEN choice(Number>1,Number, Number *100) as "Progress"