How to calculate fields using Dataview plugin?

I’m new to Obsidian, and by extent, the Dataview plugin, so I apologize if I’m asking such an obvious question. But I cannot figure out at all how to calculate fields with arithmetic operations. I checked the Dataview github, and it says that it’s supported, but there really wasn’t any examples as to how to do it. (I’m not a coder btw, so if this requires some complicated javascript stuff, I’m yeeting out)

This is my snippet:

dataview
	TABLE
		pages-read AS "Pages Read",
		total-pages AS "Total Pages",
		file.mtime AS "Last Accessed"
	FROM #queue 
	SORT file.mtime DESC

Now I want to add a column in the table that gives me the percentage of pages-read to total-pages, and then name it “Progress”

the formula would be something like: (pages-read/total-pages)*100

And the expected output would be in 10%, 20%, 50%, etc.

But nothing I’ve tried can give me the result I want…

2 Likes

Try this:

```dataview
TABLE
	pages-read AS "Pages Read",
	total-pages AS "Total Pages",
	file.mtime AS "Last Accessed",
	(round((pages-read/total-pages)*100) + "%") AS Progress
FROM #queue
SORT file.mtime DESC
```
7 Likes

it worked! Thank you so much

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