DataviewJS: Sum of Frontmatter Variables, Book Database

As always, overly hasty with the questions…

I solved it, relevant part:

let pagesum = 0;
   for(let i = 0; i < dv.pages('"Book Log/2022"').where(p => p.Medium == "Book" || p.Medium == "eBook").length; i++) {
     if(dv.pages('"Book Log/2022"').where(p => p.Medium == "Book" || p.Medium == "eBook")[i].Length) {
       pagesum += dv.pages('"Book Log/2022"').where(p => p.Medium == "Book" || p.Medium == "eBook")[i].Length;
         }
   }

I had added the .where part at the wrong spot.

Out of curiosity, in case anyone stops by, Is it possible to create a category of these variables? So I could declare the Mediums Book, GraphicNovel, eBook, Article as being in Category 1, things I’ve read with my eyes, for example; and Category 2, Audiobook, Podcast, radio, etc.

Some way to implement that in my query? I ask, because if I add a type of medium, e.g. an academic book and would like to create a type for that, I need to add that in all those queries.

1 Like