Dataview query vs Bases returning different values

Hello all! Happy New Year!

What I’m trying to do

I’m currently in the process of creating monthly notes, and one of the aspects I am adding is a section showing how many episodes of TV I’ve consumed (among other things that I’m still working on). I have a base for this as well (for more visual purposes, I suppose). The property I use to add the episode is a list watchedTimes.

Things I have tried

I’m using the following for the DV query: $=dv.pages('"10. media/12. series" and #🍿/📼/episode').where(p => p.watchedTimes?.toString().contains("04.2023")).length which returns 164. However the Base querying the same thing returns 208. I can’t figure out what causes this, so I figured I’d ask. Below is the Bases code I used. TIA for the help :slight_smile:

base

filters:
  and: 
    - file.tags.contains("🍿/📼/episode")
formulas:
  rating: if(personalRating == 5, "🌕🌕🌕🌕🌕", if(personalRating == 4.5, "🌕🌕🌕🌕🌗", if(personalRating == 4, "🌕🌕🌕🌕🌑", if(personalRating == 3.5, "🌕🌕🌕🌗🌑", if(personalRating == 3, "🌕🌕🌕🌑🌑", if(personalRating == 2.5,"🌕🌕🌗🌑🌑", if(personalRating == 2, "🌕🌕🌑🌑🌑", if(personalRating == 1.5, "🌕🌗🌑🌑🌑", if(personalRating == 1, "🌕🌑🌑🌑🌑")))))))))
  timesWatched: note["watchedTimes"].filter(value.contains("2023"))
  lastWatched: date([[8,12],[5,7],[2,4]].map(formula["timesWatched"][-1].toString().slice(value[0],value[1])).join("-"))
  epTitle: file.name.split(" - ")[-1]
  epNum: file.name.split("-")[0]
  show: file.path.split("/")[2].split("(")[0]
properties:
  formula.timesWatched:
    displayName: watched
  formula.epNum:
    displayName: episode
views:
  - type: cards
    name: April
    filters:
      and:
        - file.folder.contains("10. media/12. series")
        - note["watchedTimes"].toString().contains("04.2023")
    order:
      - formula.epTitle
      - formula.show
      - formula.epNum
      - formula.timesWatched
      - formula.rating
    sort:
      - property: formula.lastWatched
        direction: ASC
      - property: file.path
        direction: ASC
    image: note.cover
    cardSize: 230
    imageAspectRatio: 0.7

Without knowing your results—where you can see which returned notes are different between the two queries—my first guess is that your DataviewJS query requires notes to be tagged #🍿/📼/episode, whereas your base query does not.

Check whether some or all of the DVJS’s missing notes lack that tag.

Used Dataview to pull the episodes and there are a few episodes missing compared to the Base, though the episodes also have the tag, so, not sure what’s happening here.

EDIT: apparently some of my properties got autocapitalised that’s why it wasn’t recognising it :person_facepalming:

Don’t worry, stuff like that happens. Way to find it though!

1 Like