Query for sum of file.size created on a particular date

What I’m trying to do

I want to display the sum of file.size created on a particular date.

I have chosen file.size and the explicit field “Minutes_Studied” to measure of my productivity. I have been unable to query for sum of file.size on a particular day, hence I find my self here.

I do all of my productive work with obsidian whether it be reading academic books or self-help books, even dairy. If you have a better method of tracking productivity please let me know.

Please give some examples on your input data, and what kind of query you’ve tried so far.

If, by input data you mean fields then sure.

Explicit Fields

  1. Tags
  2. Date
  3. Time
  4. Source
  5. Author
  6. Mentioned_ Persons
  7. Mentioned_Locations
  8. Mentioned_Events
  9. Mentioned_Dates
  10. Type
  11. Genre
  12. Medium
  13. Page
  14. Topic
  15. Chapter
  16. Minutes_Studied

Above is a list of fields that I use. I am currently in the process of adding new fields, which is creating a arithmetic problem of it’s own while querying, which I’ll be posting here soon.

I don’t think showing what I have tried would help much since I am a novice. But, since you say so.

Table file.size ,sum(file.size) as total
WHERE date = date(2023-01-08)

It returned

As you can see I am just throwing stuff at the wall, seeing what sticks.

For a sum() to make sense, you need to group on something. Would that be the Date field of yours? That would give a query like:

```dataview
TABLE WITHOUT ID rows.file, sum(file.size)
WHERE date = date(2023-01-08)
GROUP BY date
```

(Which would make more sense without the actual WHERE clause limiting it to just this one date)

And what is this file.size you talk about. Is it the actual size of the note file? Does that really make sense to sum? Or should you rather sum the Minutes_Studied field? Which would make the query into something like:

```dataview
TABLE WITHOUT ID
    rows.file,
    sum(rows.file.size) as "Total size",
    sum(rows.file.Minutes_Studied) as "Study time"
WHERE date = date(2023-01-08)
GROUP BY date
```

Disclaimer: Untested, as I still don’t quite get some of your sample data, so that I could produce a test set of my own.

TABLE sum(rows.file.size) as "Total size"
WHERE date = date(2023-01-08) 
GROUP BY date

The above query gets me what I want. I removed “WITHOUT ID rows” from the first query you suggested, it was breaking the whole output. What does it?

Yes, it’s an implicit field, which shows the actual size of the file.

Minutes_Studied is a field that’s only in my daily note, which I use as journal. Minutes_Studied filed represents the the amount of time I spent taking notes.

It does make sense to sum file.size because currently I am into process of taking notes.

So hypothetically, I can spent a hour taking notes yet the sum of file size could be extremely low, indicating low efficiently.


Thanks for your time,holroy. With a little bit of practice I think I’ll be able to perform the sum function without asking for any help.

With removing that you removed two functions, which often comes in handy in some situations.

Using TABLE WITHOUT ID will take away the first column with the link to the originating file. When it comes to doing group sums, that is often not wanted, which is why I added it, but more out of habit than per your request.

The second part is that whenever you apply GROUP BY to a query, much of the information precious reachable directly like file.size is now grouped together into arrays/lists under rows.file.size and similar. This causes a lot of confusion, especially for new users, as the query used to return this, and now that is gone are reports strange stuff (but it doesn’t as it’s now found as lists using rows. ... ).

There are also some pecularities related to seeing the individual values vs the list of values related to using rows, and in due time FLATTEN, and so on. But don’t worry about it, when you need some of that functionality you’ll either find it documented, or you come here again and ask what’s happening. :smiley:

Well, I have already run into another problem, i suppose I’ll be learning by trial and errors.

Thing that I am trying to do

TABLE Computer_Science, English, Business_Studies
FROM "Permanent/Diary"

Above is the query and it’s result. You can see on which day I studied which subject and for what amount of time. I scrapped the time for “Minutes_Studied” (Tho I have still have it in my front matter in case this idea doesn’t work out)

Minutes studied was a aggregate of all subjects, but I thought that it’s also important to take a note of on which subject I spent how much time.

Hence, I added the subject names as fields in front matter of my daily note.


But I ran into a problem

TABLE sum(Computer_Science + English + Business_Studies)
FROM "Permanent/Diary"

And

TABLE English + Business_Studies + Computer_Science
FROM "Permanent/Diary"

Both doesn’t work, it returns a “-” in every row of the sum column

BUT interestingly

TABLE English + Business_Studies 
FROM "Permanent/Diary"

Returns

As you can see in first screenshot, I studied English for 25 min on the 6th but that daily note doesn’t even show up on this.

Nor does Business_Studies show up even tho I studied it for 3 hours on 9th

I am trying to get the total minutes studied on a day by adding the time I spent on
each subject.

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