Displaying a list based on a metadata's value

Things I have tried

I tried looking at the docs but can’t seem to find any if statements and such…
I tried WHERE but can’t figure out a way…

What I’m trying to do

I have a file that acts as a hub for my notes. Let’s call this Hub.
In the metadata is → quarter: 1
Where quarter can/will contain 1, 2, 3, or 4.

In my notes, there are 2 tags: #grade and #grade/q1 #grade/q2 etc.

With this, I want to make a LIST where it displays notes with the tag #grade/q1 if quarter = 1… or #grade/q2 if quarter = 2… so on and so forth.

Here’s what I got so far:

LIST FROM #grade/q1 AND -"Templates"

yeah… I really don’t have much progress-

Why am I doing this if I could just make a copy for each quarter?

Well, I’m going to add this for 12 different subjects for school. Frankly, if I had done the long and tedious approach, I would’ve probably gone insane.



1.How to filter by file.tags?
2.How to filter by file.etags?


  • dataview: v0.5.41



the current file

  • filename : Hub
# other stuff

quarter: 1

dictionary files

  • filename : dic_20090101
date: 2009-01-01
subject: JavaScript

  • filename : dic_20090401
date: 2009-04-01
subject: JavaScript

  • filename : dic_20090701
date: 2009-07-01
subject: JavaScript

  • filename : dic_20091001
date: 2009-10-01
subject: JavaScript



4.1. Main DQL

Code Name Data type Group By Purposes Remark
DQL10_display_notes_where_this_quarter file.etags or file.tags no 1.require this.quarter

2.FROM file.tags

3.To fiter by quarter

4.To filter by file.etags

5.To display the metadata as a table

Code DQL10_display_notes_where_this_quarter

title: DQL10_display_notes_where_this_quarter =>1.require this.quarter 2.FROM file.tags 3.To fiter by quarter 4.To filter by file.etags 5.To display the metadata as a table
collapse: close
      this.quarter AS "this_quarter",
      file.etags AS "etags",
      file.tags AS "tags",
      subject AS "subject",
      file.link AS "File"
FROM "100_Project/02_dataview/Q95_etags/Q95_test_data" AND #grade
WHERE this.quarter
WHERE contains(file.etags, "#grade/q" + this.quarter)
SORT file.name ASC



I think there was a misunderstanding here… but thank you for the answer any way!

I’ll try explaining it again.
The notes’ metadata contains quarter but only Hub,md actually has that. Now, note that Hub.md will only, and always will, represent a single grade (#grade)

In Hub.md =>

# other stuff

quarter: 1

Now, why not just add quarter in the notes’ metadata and be done with it?
Because there is a possibility that these notes will be part of another group (grade in this case)
So, let’s say a note named note1.md is in #grade12/q1. If we put this data in the metadata, at some point when note1.md will be part of #grade12/q2 or even #grade13/q1, the metadata will either be overwritten or duplicated (which is inconvenient). What I’m trying to say is that it is easier and more maintainable than just adding the quarter to the metadata.

What am I trying to do with this exactly?
Hub.md contains a list of subjects.
In each subject is a list/table of all topics covered in the grade, BUT I only want it to show topics covered in a specific quarter. The quarter in Hub.md’s metadata determines which quarter to show. So, if quarter = 3 in Hub.md’s metadata, the list/table will only cover topics tagged with #grade/q3.

Considering that there are 12 subjects in my case. I’m too much of a lazy person to create a copy and edit 48 different instances.

From @justdoitcc 's solution, you could take out the line WHERE quarter and the line quarter AS "quarter" and use this.quarter instead of just quarter in the second WHERE. Assuming your query is written in the Hub, which has the quarter field, it should work.

The DQL is updated!

1 Like

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