How to sum a column in a dataview table

I have a folder with files for each sale of an item. The files contain Name, DateOfSale , Quantity, Cost, Notes .

Here is an example file:

Name:: Some Person

DateOfSale:: 200508

Quantity:: 1

Cost:: 285

HowTheyFoundMe:: Facebook

Cell:: 123-456-7890



Notes:: Owns party business.

I use

TABLE ("$" + Cost + ".00") as "Total Amount" 
FROM "Woodworking/Thing/Sales" 

to give me a table of all the sales showing the cost in one column “Total Amount”

I want to then get the sum of this column to give me the “Total cost” but can’t seem to figure out how to do it. I have searched and searched but can’t find an example where this is done.
There must be a way. Can anyone point me in a direction?

Another way to put this in words would be: how could I read one field from every file and add them all together and display it?


I’ve never actually had a use case for doing this with dataview even though I use it heavily

The post from here in this forum may help

@gregp , that was totally helpful! Thanks.

So I figured this will give me the number I need in my case:

TABLE sum(rows.Cost) as TotalCost
FROM "Woodworking/Thing/Sales"
WHERE Cost != null

The only thing now is that this is kinda shown in a table in the middle of the page.

Group	         SalesCount
-	                    13

Do you perhaps have any idea how I could do the same but show it something like this:

Total sales: $3546

So basically put that total into some text somewhere on my page where I choose?

Just in case anyone is interested, I also figured out from that post how to get a count of the number of sales entries I have that do not have a $0 cost:

TABLE length(rows) as SalesCount
FROM "Woodworking/Thing/Sales"
Where Cost !=null

Gives something that looks like:

Group	TotalCost
-	      3925

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