What I’m trying to do
I want to sum all the values in the “Preço” column, but I don’t have any ideas of how I’m going to do that. I’m almost a total noob when it comes to coding.
TABLE WITHOUT ID
file.link as "Despesa", "R$ " + Preço as "Preço"
from "Dados/Despesas"
sort Preço, file.link asc
This is the code that I used to create this dataview table.
Perhaps there’s a simpler way to do this (maybe even in DQL), but the code below works.
(You need to enable DataviewJS in Dataview settings)
~~~dataviewjs
const rows = dv.pages('"Dados/Despesas"').sort(a => a.file.link).map(a => [a.file.link, "R$ "+ a["Preço"]])
const total = Array.from(dv.pages('"Dados/Despesas"')).map(a => a["Preço"]).reduce((s, a) => s + a, 0);
let rowsArray = Array.from(rows)
rowsArray.push(["Total", "R$ " + total])
dv.table(["Despesa", "Preço"], rowsArray)
~~~
1 Like
system
Closed
December 25, 2023, 6:15pm
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.