Help realizing this workflow scenario, please

Things I have tried

Searching similar scenario(s) in this forum. Didn’t find any.
Trying to take various pieces of code or hints here and there. Didn’t succeed.
That’s why I’m posting this…

What I’m trying to do

I’m a teacher, and on a daily basis I would like to take note of what I do in each class.
I created a single note (.md) for each class I teach in (let’s call them “1A”, “2A”, “1B”, “2B”).
Each note has some informations on each class (say the names of the students, the topics I need to talk about etc).
I would like to be able to automatically populate the topic I taught in each class, starting from Daily Notes (core plugin).

For instance, in today’s Daily Note I would write

1A - Lorem Ipsum
2B - Dolor sit
1B - Amet consectetur

And I would like to see in the “page” of 1A something like this:
2021-09-13 - Lorem Ipsum

In the page of 2B something like this:
2021-09-13 - Dolor sit

and so on.

I can guess that this would be a great work for Dataview (or maybe even DataviewJS), but I’m not that good at using code…

As I don’t know very much about queries and programming language, any hint on how to improve my knowledge would be great, much more than only posting the query code.
Of course, if anyone has a better way of solving this problem (i.e. changing the workflow), please feel free to post suggestions!

I don’t know much about programming language either, but queries on dataview are pretty simple. For your case, write in your daily note :

  • class A:: Lorem Ipsum
  • class B:: Dolor sit
  • class C:: Amet consectetur

(avoid numbers in names, i couldn’t get it to work with them, i don’t know why). Then in you “pages” write :

TABLE, class A
FROM "daily notes" (if the folder where you keep them is name like this)

A summary about how the plugin works

you have to have data in some files with its respective value, it can be written in one of these 2 formats :

  • inline fields : this format can be put anywhere on the file data::test
  • front matter : this format has to be written at the top of the file with the 3 dashes above and below
data: test

you can also pull data from the file via dataview added metadata, like in our example we pulled the date of the file with
The data can be many types : dates, tags…
Then you can query the data with 3 views (table, list, task). For tables, you have to specify the column name which are the names of the data, in your example it’s date and You can also rename them with “AS” like AS date
Then you can use FROM to specify the source, WHERE to filter and also SORT.
I think this will be enough for most of your use cases. But you can read the full documentation if you plan on using the plugin a lot.


Hi! Thanks for your answer and sorry for being late to thank you, but I had some kind of “heavy week”.

Thanks for the explanation, too: that’s what I was looking for.

I will definitely try your query and will try to figure out why it doesn’t work with numbers… I wouldn’t want to rename all my classes, as it would be a real pain to find relevant informations if I change their name (italian system… not my choice…).

1 Like

I am able to use numbers in the field names with Dataview as long as they aren’t separated by a space. For example:

class-1:: Lorem Ipsum
class-2:: Dolor sit
class-3:: Amet consectetur

Thank you both, @imed and @Montblanc.

I used Montblanc’s code with imed’s suggestion, and it works… kinda… see screen:

I created a “fake” topic on today’s DNP (left side of the screenshot), and dataview correctly “found” it (right side). But I can’t understand why there are “unwanted” results, and there are more than fifty, none of which has “classe-4AC” in it. It’s like if dataview reported all DNP and not only the one(s) with “classe-4AC” inside.
Should I use some functions like “contains” or “containword”? I tried using this, but all I get is an error:

FROM "Daily Notes" 
WHERE contains("classe-4AC")

It seems that the function “contains” needs a different argument to work…

1 Like

You could use this:

TABLE, classe-4AC
FROM "Daily Notes" 
WHERE classe-4AC" != Null

There is potentially some value in seeing a blank result (e.g. did you forget to fill it in on a day), so you could also use a starting point.

TABLE, classe-4AC
FROM "Daily Notes" 
WHERE >= date(2021-09-22)

@Montblanc It work-ish: the “date” thing at least avoids having dozens of empty items, but:

that’s the output:

(of course it stops at sept 13th).

This is the code:

TABLE, classe-3AE 
FROM "Daily Notes" WHERE "classe-3AE" !=Null 
AND >= date(2021-09-13)

Try removing the quotation marks from
“classe-3AE” in your where statement. I don’t know if it matters, but also try putting a space between the equals sign and the Null statement.

Also, if you don’t want to see blank values no matter what, you shouldn’t need the date check once you get the other part working.

It worked!

Here’s the code:

FROM "Daily Notes" 
WHERE c3AQ != Null 
AND >= date(2021-09-13) 

Some points:
0) I abbreviated the argument from “classe-3AQ” to “c3AQ” just to avoid typing useless characters before the “name” of the class

  1. I don’t know why, but dataview needs the argument to begin with a letter and not a number (I mean: TABLE, 3AQ won’t work, but TABLE, c3AQ does… it’s some kind of mystery to me…)
  2. I don’t understand why if I change the c3AQ:: Lorem Ipsum with something more “human-like” like c3AQ - Lorem Ipsum (or whatever else) the query doesn’t find any result. Ok: I get that the :: is some kind of “pointer” for dataview, but is it the only one I can use?

Anyway, thank you all: I begun understanding better how queries work (especially the != SOMETHING part: it’s genius!!!)

EDIT: I decided to keep the “after this date” thing to be able to filter last year’s courses with the same class name

From what I can tell, there’s no way to change the format for the inline fields. You can use YAML front matter if you prefer.

If you need to separate these by academic year, you may also want to consider placing an upper bound on the date as well.

1 Like

Some notes:

  1. About the command WHERE, it filters the pages with the clause you write. In your last example, you just need to write WHERE c3AQ (the query presents only the pages with values in the field c3AQ). The != Null it’s unnecessary.
  2. The function contains checks if the one field has a specific value in it: contains(field, "value"). For example, something like WHERE contains(c3AQ, "test di argimento")
1 Like

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