In this video I'm going to go through the DataView Obsidian plugin which is a plugin inside of Obsidian that queries your files. So Obsidian is essentially a big folder and DataView lets you search for specific files using filters, using sorts, and using any other expressions or functions. So things to filter down what files you see in lots of different ways giving you lots of flexibility but it can be confusing hence the video. For a bit of orientation you can see this is a new vault so the main vault folder is called data view explainer and then inside that I have a data folder with two files me and then my podcast co-host and then this example file which is outside of the data folder and I'm showing it twice. In this left view if I click on the three dots you can see it's in source mode.
What that means is if I push hash and then say header this is markdown But when I push enter I can always see the source code so I can see the hashtag whereas in this other view of the exact same file, so this is the same file, this one is in a live preview. You can see it's not in source mode and it shows what it's meant to be. If I get rid of this hash it's going to show the text and the reason I've done that is so that we can see what's going on in the query and what it actually shows when it renders.
Then I go bottom left settings, go to the community plugins and what I've done is I've browsed for a community plugin, I've found DataView, I've installed it and then inside of the settings, so you can see I'm in the DataView Obsidian plugin settings, I've enabled inline queries, enabled the JavaScript queries and enabled the JavaScript inline queries. Everything else kept exactly the same all default. So now when I push the three ticks on my keyboard you can see we've now created a code block and in the right side it's going to show a code block which you can copy to your clipboard.
By typing data view you can see it's turned the code block into a data view query but there's a data view error passing failed in other words there is something inside the data view query that doesn't work and it says the expected error is that I haven't put in a type of query result. Quickly looking at the settings you can see there are JavaScript queries and then there are normal default queries and you may see things referred to as DQL so DataView Query Language or DVJS which is DataView JavaScript. At the moment this code block is DQL because it's the DataView Query Language however if I put JS at the front of that this is now DataView JS and this uses JavaScript inside of the queries.
So sticking with the DQL, the DataView query, I'm going to type table because that's the first type of result I can show and now it's showing a table of my entire vault. So we've got the Danny Hatcher file, the John Stewart file, and the example file inside of this DataView explainer vault and what the query is showing is all three of those files. If I was to change this to a list it's going to do the exact same thing but you can see now there's a bullet point and it's showing a list.
If I change this to task at the moment it's going to say there's no results because there are no task blocks inside of this vault. And inside of obsidian there is markdown for that which is a bullet point with some square brackets in between. So now I've added a task to the file you can see it's tickable and now it's going to show that inside of the data view query because it's looking for all of the task blocks. So if I add a couple of tasks you can see the query will update and say first task, second task and it will find them all. And then the fourth type is the calendar but this is limiting and can be kind of buggy as well when you get into using other things so I personally would avoid using the data view calendar and use another plugin for calendars inside of Obsidian.
Now going back to our table, a table has columns normally and at the moment there are no columns apart from the main id which is the file and then showing the three files. And because this is only showing a table, it's not a table in itself, it's a result, we need to create the columns or the field information inside of the file. And going to the DataView help documentation, going to the data types, you can see there is a field type section. And if we look down the right side, you can see all of the different types of fields. There can be a text field, a number field, Boolean date duration link, list, and then...
object. If I click on my name and I go to the file you can see here this is a property. This is one of the properties inside of Obsidian and this is a field DOB as date of birth. And when I click on the icon you can see property type we have text, list, number, checkbox which is the boolean field type.
date and date and time. The data view link option is inside of the default text properties and at the time of making this video the obsidian object field isn't available inside of the properties. In this view you would need to go into the source mode and then add it. The reason this looks out of line is because I've zoomed in so you can see the text which has obviously confused obsidian a little bit.
But in addition to these main properties and these main field values at the top of the file the DataView plugin also lets you use inline. So these are inside of the file. You can collapse them and open them, but you can have inline properties by typing words, then using two colons, and that is going to be the value. So the terms used by DataView, DOB is the key, and then the date is the value.
Country is the key. At the moment, the value is empty. Color is the key.
Blue and orange is the value. So here, inline is the key and now hello becomes the value. So if we jump back to our table if we type in a key if I type in dob because that's the key it's going to show the value so you can see the date of birth of both of these people is actually the same date and when we have a look at the file you can see the key is dob so that's the key here and then the value is the actual date and when we take a look here remember inline is the key hello is the value so if we come back here type inline you can see inline is now the column key and then the value is the actual information and data view also lets you use inline values within words within sentences you can see danny hatcher in the source mode there's the key there's the value and this is the syntax for properties and then this is an inline so you can see i've got the square bracket to start square bracket to end and then the two colons in the middle this is inline information which shown in live preview or in the reading view you can see we've got the properties which have rendered properly as you would normally see and then this has some highlights on it because this is information data view can see which you can come in and edit and when we go back to the table it doesn't impact anything because the key and the value are still accurate even though it's inside of a sentence Now something to be aware of is because DataView likes to have what it calls sanitized metadata, so information it can see, what it will do is it will connect words with dashes, remove bolds and other syntax, so you can see it's removed the capitalizations and it's added it all together as one sort of long string and if you add any bolds or italics or anything like that it will also remove it to sanitize that information.
And what that means is when we look at this key, so that's capital D-O-B, and then we look at this key, there's a capital I and then inline. Inside of this file, we can see all that information's accurate. And when we show this table query, this is the capital I, which was accurate, and it's showing hello.
If I change the capital to a lowercase, so now we've got inline, it's still showing hello. If we type in lowercase D-O-B, it's still showing the date of birth. even though we've got the capitals in there, which makes it easier to keep things going, so it doesn't sort of like cross over anything or forget anything or leave anything out.
But these fields aren't the only fields you can use for data view. There is also a long list of what they call implicit fields. So these are fields that are already built in with data view.
So file.name, file.folder. They will reference specific things in Obsidian that you don't have to add. So if I type in file.ctime, that's the created time of the file inside of the table, it's going to show the created time of the file. And that is an implicit piece of information.
However, when you look at tasks and lists, instead of tables, that's a type of view, there are different implicit fields. Because in a task, there is a status of a task, whether it's ticked or not. So checked, completed, fully completed.
So you can actually check. different implicit values with a task query when compared to a table query. So if I type completed inside of the table query it's not going to show me anything because inside of the Danny Hatcher file there is no key that says completed and there's nothing implicit for DataView to show. However if we look at a task query so we've got one task that's uncomplete and one task that's being complete you can see there's the tick box and I can tick this and it would change it to put an x in it or not.
Now I can ask the task query where it's completed and where is a way to filter this query for implicit information i.e. it's completed or not. Now just as a quick point you can bring tasks into a table view so you can see I've got a table and I'm referencing file.tasks.text and then I'm calling this text so that's the text of the task so task and then task2 but I can also add in the completed variables inside of this table, so it's not unique to the task query, but the task query does mean you don't have to do all of this dot stuff, which I'll explain later on with the flatten and group by. So it is doable inside of a table query, but in my opinion, it doesn't look as clean and it adds a bit of complexity that you may not want to deal with.
And in this case I can put an exclamation mark to say not. So now it's looking for tasks where it's not completed. Completed using implicit information. Which is showing the task that hasn't been complete.
Now coming back to the data types quickly. Text, you can look for words inside of the value. So we've got the key, then we have the value. Text, you can look for words. But a number, you can't look for words.
But you can do arithmetic. So depending on the data type will change what you're able to do. Boolean you can check to see if it's true or false but numbers is not a true or false because there could be lots of different numbers in there, positive, decimals, etc.
And we need to bear that in mind when we're doing queries because if I'm looking for something that is true or false and comparing it to say a number, well I can't say a number is equal to true or a number is equal to false because they are two different data types. So now let's have a look at the data view structure, a query structure. You could add a task type which is what we've done.
We can add task and it will show all of the tasks and then add in something underneath. We could add a list type and that shows the bullet point list and add one field. So I can put date of birth but it doesn't let me add another field. You can see I've got list, date of birth and vip so these are two different fields and it's showing an error.
and it's pointing to the error which is the comma. vip is a key and it has a value but because the list type doesn't let me have two fields it's showing an error. However if I have a table I can have as many field types as I want.
So the list is showing the error if I change list to table it's now going to show date of birth and vip as false. Then you have from which lets you specify where you want it to search from, so it gives you a source. At the moment we don't have anything in the from, so DataView is assuming it wants us to search everything, which is why it's showing these three files. Bear in mind that the from needs to be after the type of query.
The rest of these can be moved up or down, but if the from has something before it, DataView won't use this from argument. But if I type in from, it's throwing an error because I haven't told it where to search from. Looking at the data commands inside of the DataView help docs it shows you how to use from, how to use where, sort, group by, flatten, limit, all the other commands we're going to use and you can see we can search for tags, folders, single files, links and that's links to or from.
So if we have a look at the Danny Hatcher file at the moment there is a tag that says example. So if I want tag from, hashtag example, then come back to the table it's now filtered my table view to look from the files that have hashtag example in it. If I remove the tag from Danny Hatcher and go back to the table now there are no files that is from hashtag example.
When I add the tag back, go back to the query, it's now showing my file. I can look for the data folder so I've used speech marks, put data in the middle because data is the name of this folder and it's showing the two files inside of the folder, Danny Hatcher and John. I can right click, create a new folder, me, put myself in the me folder, and now if I want to look for just me I can go slash me.
So now I'm looking for data and me, so I'm looking for the files inside of the me folder, not just the data folder, or I can remove the folder and look for just this file name. And what I've done is I've added the entire file path, so I've said look for the data folder, and the file inside it called danny hatcher and now it's showing just my file. Now at the moment danny hatcher doesn't have any links going to or from it so if I go square bracket square bracket and link it to john so now I have a link from danny outward to john and if I go to john there is no outward link to danny but if I look to the right side and see the backlinks panel there is a link from danny to john which is the one we've just made You can see go back this one's out from Danny to John and this one's back from Danny to John. Inside this data view query if I type bracket bracket John Stewart it's looking for files that go to this note and we have a link that goes from Danny to John. So this is looking for the back links but if I want the outgoing links I surround it with outgoing and then open bracket close bracket and because there's no outgoing link it's not showing anything.
So I add Danny Hatcher. Now there is an outgoing link from Danny to John which the core Obsidian plugins actually already show. So there's the backlinks and there's the outgoing links. On John there's no outgoing links but there's a backlink.
On Danny there's no backlinks but there is an outgoing link. You could then combine these together to be more specific. So I'm looking for files from the data folder, so example's not going to show, and has hashtag example.
So it's going to show me because I have the hashtag but John doesn't. I could then say from the data folder and not by putting a minus before this, so this has not got the hashtag example, and now it's showing John. I could say anything that is not in the data folder by doing the same sort of thing by putting a minus before that So now it's showing example because that's not in the data folder I could then look for anything that has a hashtag or as the file path example So I'm now looking for the example hashtag or example So we've got the Danny Hatcher because it's got the hashtag and the example because that matches this file path Now we have the WHERE condition and this allows you to add expressions or more advanced filters rather than just a source.
So looking at this, because there is no FROM, it's looking for the entire vault. And I've added WHERE, but it's giving me an error because I haven't put in an expression. So if I type in a key, DOB, that is a property field key, it's now looking for where there is a DOB, a date of birth.
as both of these files have a date of birth they are going to show. So where shows positive results. Where this expression is true.
If I put an exclamation mark in front of this it's looking for where there is no date of birth and the example file doesn't have a date of birth so it's going to show inside of the query. And this is where understanding data types is important. If we go to the Danny Hatcher file.
we've got a number. If I add a number in here, say 27, and I say where number equals 27, it's going to be true. But if I put 27 as the country and say, is country equal to 27? Country is text.
And if I come back to the query, it says, no, there isn't anything that matches this. This isn't true, but it is because 27 is there. But the difference is this is being told to date view as this is a number, this is text. So I need to put this into speech marks to say to DataView this is a string, this is text you're looking for, and now it's going to find the file.
And if we go to the top right of the file, click the three dots to go into the source mode, you can see this is how Obsidian is telling DataView that information. So this is text, whereas this is a number, so it's inside the source metadata of the file, not just DataView's just knowing it implicitly. So when we're looking at DataView expressions and we scroll down, you can see we've got the field expression type and there are literals, which are constant values.
Things like one, hello, and anything you've written in. So when we put that 27 in speech marks, we were creating a literal and comparing it to a key. Country being the key, 27 being the literal that we were looking for. You can do arithmetic, but bear in mind that if you're trying to do arithmetic or math.
With numbers, it will work. But when you do math with words, it won't. So as a basic example, we've got a query looking for everything, and it's doing 27 add 3. And it's doing that calculation inside of DataView to give us the number. But when we ask it to do 27 add 3, the word 3, 27 is a number, 3 is a word, DataView says, I can't do that.
And then when you try and add words together, it gets confused because it doesn't know whether this is... one key, this is another key, and this is another key, or whether it's all meant to be one, which is where we need to put speech marks around the entire key so DataView knows, okay, all of this is meant to be together, this is meant to be all combined, which is 27 plus 3. You can still use the plus as a way to combine different numbers and text together, but you can see you need to tell DataView what's what. So 3 is a string, so I've surrounded it with speech marks, and then 27, so the plus is concatenating, or putting them together. So now we have 27 add 3 and that is being the, it's not the calculation but that's what's happening, so if I put a space in there you can see now 27 and 3 are together and if I replace 27 with the words inside of speech marks I now have this string concatenated or added to this string which leaves me with this. And you can use the arithmetic inside of any part of the query so when we come down to comparisons you can see price is greater than or smaller than a number price being a key inside of obsidian files, 10 being a literal number, and then the greater than sign being used inside of the where clause.
So looking at our example we've got a table, we're showing the number field value, so there's the number, there's 27, where the number, the key, is bigger, the comparison operator is bigger than 0, well 27 is bigger than 0. If we want numbers that tall. smaller than zero, change the comparator, well now we've got John Stewart which has no number, an example which again has no number so it's smaller than zero. And you can do that with the implicit values so they can be dates, durations, any other information you can add inside of Obsidian I've previously mentioned.
Also adding in list and object indexing. So when we have a look at the color key, that's the color field, at the moment it's a list field so we have blue and orange. orange as two different values so they are list values and when I look for table and color it will show both of those different values inside of the column and if I add square brackets at the end of this key and say 0 I wanted to show the first value of that list or array so when we go to Danny Hatcher the first one is blue go to the example the first one is showing is blue because it starts at 0 then to 1 so if I go to 1 it will show the second value in the list. Go to Danny Hatcher, orange is now showing the second value.
If we go to number two, well there isn't three so it's not going to show anything. So you can look for anything inside of the list value. Then we get on to functions. Now inside of the Obsidian documentation you can see there are lots of functions. I will go through a couple of them later on and I may show some examples later parts of the video.
but there are loads of functions that you can add which do lots of different things, which is where much of the complexity and flexibility and extensibility of this querying language can be used, which obviously adds complexity but goes beyond a lot of the other query languages that other apps use. So I'm going to use a where clause and I'm going to use the function contains. And when we look at the contains function, you can see you can look for an object, a list or a string, and then you input a value.
So very similar to the key, so any sort of key in there and then a value here. So if I go to the country of Danny Hatcher, add UK, this is text, I've now added contains, the key being country because that's the key I'm looking for, comma, and then I'm looking for text so I'm using speech marks, and then UK as the value because I want everyone where the country contains UK. And so now it's showing me. If I now go over to John and add UK in for John, go back to the example table, you can see now John is showing because John's country key contains the value of UK.
Lambdas can also be used inside of expressions as advanced literals, often inside of functions that are kind of complicated, which I'll touch on in a couple of later examples. And then you can also index through links. I personally haven't found a use for this. But if you put a link, then use dot, then use the key, you can find values from a link inside of the data view query.
We then have flatten, which then creates a row for every true result inside of a query. Dovos, one of the data view helpers inside of the Obsidian Discord, explained this to me as it's like creating a new key, new property, new piece of metadata. So when we look at the color key.
and we look at the two values, blue and orange, this is one piece of metadata. It's one property. But if we flatten the color, each of those values has now been created as its own individual row. So you can see John showing up twice because the value is now its own piece of unique metadata, sort of.
And good practice is to name what this is because it's not labeled anywhere, which is what the as F is for. But now that I've renamed this, the table is confused because it's looking for color. So it's showing the color and then splitting them up with accordance to the flatten C.
So DataView recognizes that John has two C colors. It has two colors. So it's showing two results. But the table is showing color. So it's showing both of those results, which means I need to change what the table is looking for because the table is actually meant to be looking for C.
So now it's showing the individual result rather than all of the results through color. And then you can add a where clause after the flatten so you can see I'm looking for all of the files where there are lists. So the example has a list which is a bullet point that could be a numbered list as well and I'm flattening to file.list as l so l becomes each of these different new pieces of metadata we've sort of created with flatten.
But then this where after the flatten is looking for anything that contains L.text so text inside of L that is hello. So if we have a look into the Danny Hatcher file you can see there is a list point and it says goodbye in here we've got it filtered for hello if we remove this line you can see now it's looking for goodbye and hello because that's the text that we've got in here it's showing all the files lists it's done that but to add the where clause it then filters out specifically for what we flatten. So that's why you'd use a where clause after a flatten and potentially one for it. But the group by does quite literally the opposite of flatten.
It groups, i.e. brings all of the files together. So I'm grouping by date of birth. So every file that has the same date of birth will appear in date of birth. But because all of the files have now been condensed into one result, date of birth, I need to find the rows again. So I need to type rose dot and then the information I want to see in this case I want the file link so you can see John and Danny both have the same date of birth an example doesn't have a date of birth and you can look for specific keys so I'm looking for the color key related to the date of birth so you can see this dot represents a file but I'm not showing the file and then it's showing the color this dot represents another file which I'm not showing and then the color and looking down here we then have sort so i can sort by number so i'm looking for the number key in ascending order so we've got 14 then 27 or a descending order and i've got 27 14. now you will have noticed because the number here is essentially zero when you go to ascending order it's always going to show something with no number at the top which is where you can add a filter that says where There is a number.
So if there is a number, it's going to show. If there isn't, it's not going to show. And I'm sorting that by number ascending, which is there.
And again, if I go to descending, we have it there. If I was to put exclamation mark, it brings in example. And now the sort kind of becomes redundant because they're all going to be zero. Now if I go to John you can see he is in the UK but I've changed myself so I am now from Germany so country Germany and then John country UK. What I can do is add a custom sort and this is where it gets a little bit more complex so I have a function default then I'm using a lambda so X is there and X is down here and what essentially I'm doing is asking if it's UK give it a value of one.
If it's Germany, give it a value of 2. And what I want you to do is look at country. So that's the key. And the value are here. So the values UK and Germany are here. The key is down here.
And this is the other. And I want you to order that in ascending order. So UK 1, Germany 2. And when we look at the table, you can see UK is 1, Germany is 2. If I was to change this.
descending order the example has gone back to the top because it's at 99 and Danny Hatcher Germany is there and UK is there so if we go ascending and change the UK value to 2 and the Germany value to 1 you can see Germany is now at the top and UK is now second and you can add as many as you want so I can go colon USA 3 now I don't want to put a colon because that's going to close this out so USA is now three. So Germany first, UK second. And if I was to add a new person, so I've got new person.
The country is from USA. You can see USA is three. So Germany is one, UK is two, and USA is three. And this is a custom sort, which you can, of course, add all of the other from where flattened group by sorts on top.
But what if you don't want to see all of the results? Well you can limit it by putting limit and then say 2. So now it's limiting the results to the top two and if we were to change this to a descending order is now showing the top two of this sort and you can limit this to as many as you want. Now unique to the table view is these columns because inside of the list view you don't get any columns.
So when we're in the table you can rename these columns. Inside country I could say as State so it's looking for the country key inside of the files, but it's naming the column as State the first reason this is useful is because we can remove this first column by adding without ID So it's removing the ID of the data view query But I still want a first column with the link so I can add this back in as just a column File dot link and then make sure there's a comma because I need to separate these two columns now. I want to name file.link, I don't want it to be that, as name. So now I have a first column of file.link, and I've renamed it to name. So instead of showing all of the calculation-y stuff that DataView is doing, it's just showing something quite nice.
But if I say name of person, because there are spaces, DataView doesn't know whether these are individual keys. Again, I'm going to put quote marks around them to say name of person is the name of this column. Something else you might want to do you can add a function anywhere inside of a query. So I'm going to use the join Function put a bracket and then close that out.
So now I've joined the list of color together So now blue and orange is a joined list rather than the bullet point results It shows by default, but now my column doesn't look very nice. So I'm going to rename that as Color so now I have color as the column title and it's joined the color key to make it look better. Now for vip that's a boolean so if I tick this we go to example column vip we've got true or false but I want this to show an emoji so I'm going to use a different function inside of this title and say choice open the brackets so it's going to look for the key value vip but now I need arguments I need the answers of whether it's true or false.
You can see I've got choice, I've got the key, VIP, and then at the moment I have the words true and false being shown, which mimics exactly what it's supposed to. So we've got John Stewart and John is true, it's correct. But I want this to be an emoji, so I can go into my emoji menu on Windows, that's Windows dot, on Mac I think it's command shift space. I can add in those emojis inside the speech marks, and now you can see I've got a tick. or a cross instead of true or false.
The column still doesn't look very nice so I'm going to say as vip. So now we've got three nice looking columns. I still have this example which I want to remove which I can do by saying from the data folder because example is not in the data folder.
Or I could add a where clause that says where the file name does not contain because exclamation mark contains example. So I've now removed any file that has a name that contains Example and there's loads of other different ways you could do it which just shows the flexibility of these queries I'm going to clear this up a little bit So I'm going to remove all of that so you can see we've still got these files in there But now I want to do a calculation So I have the date of birth of all of these people so DOB shows the date of birth but because of the literals the data view uses I can say date bracket now and then minus dob so now i have the age in in milliseconds obviously i don't need milliseconds but i could then rename this as age so now i have my age in milliseconds or the age of these people in that time and borrowing from davos a little bit you can see we have a much more fleshed out example which if i go to john and change his birthday to the 15th of uh october 96 You can see John will be 28 on the 15th of October 2024 and that's their date of birth. So it's working out the person's next birthday and how old they will be. All from just the date of birth key and value inside of their file. So let's have a look at how Dovos did it.
We've got the table. It's without id so it's removed the first file and it's added that column back in and called it name. We then have a column for date of birth, which is the key value we already have, so that's nice and easy. But then we've got will be, and when we look inside the file, will be isn't anything inside of here.
It's not a key that he could use, and neither is on. So these columns have been created inside of this query. Now we've got a source, so it's looking for the data folder, so that's the data folder here. So we've got one, two, and three, so new person could also be here. but there is an additional expression inside of a where clause that says where there is a date of birth.
So if we go into the new person, there is no date of birth. So it's not being shown as a result and that there is no DOD. So that's date of death, which is something Dovos uses in his example template linked in the description below.
So we're filtering out files we don't need. Then we have a flatten and that creates rows for a unique. property key value that they are creating.
And this has been named as this year age. And the calculation is using the literal date for today, the year. So it's looking for the year of today. It's then using the date of birth, which is a value we already have, looking for the year of it.
And that's this year's age. So if I come in here and put this year age, As a column you can see it's created this year age in here. But we don't really need that. However, this year age can be used inside of the next flatten.
So we've got date of birth plus the duration. So all of this is a duration and that is named this birthday. So we have this year age, so that's 27 at the moment, and turning that into a string. So it's changing the number, this year age, into a string that also has plus a space and then years.
So when we type this B day, it's showing October 27, 2023, because it's added the date of birth, which is in 96, to the current year's age, which is 27. So 27 added to 96 is obviously 2023, and that's the date. but we want to know how old that person is going to be so we've added flatten then choice so remember that is a value and then it wants a true or false for it so this birthday is bigger than today if the birthday is bigger than today then it's obviously in the future and if it's in the future we want it to show the current age so this year's age however if it's in the past Well, it means there's a birthday coming. So there will be another year on top of today's age, which means we want to do this year add one. So they will be, in this case, John will be 28 on the next birthday and I will be 27 on my next birthday.
But then we want to know when the next birthday is. So again, we're doing choice, this birthday, and then is that bigger than today? If it's bigger than, then obviously it's coming up, so this birthday. If it's not, then it's in the past, then we need to add another year.
So this birthday, add duration of one year. And then that's going to be called on. And the entire query is also sorted by that field.
So it's being sorted by on. In other words, the most recent birthday, so the birthday coming up, is at the top, and the birthday furthest away is down the bottom. So I was born on the 27th of October 96. I will be 27 on the 27th of October in 2023. John was born apparently on the 15th of October 96 and they will be 28 on the 15th of October in 2024 because we've already gone past the 15th as I'm recording on the 23rd.
So this birthday is still to come this year whereas this birthday has already happened this year which is why it says 2024. Here. we have another example. Now this could be done with the tags plugin but this allows you to be a little bit more specific about your queries of the tags you're using.
So we have table and then we've got a length and the length is calculating a number. So how many there are and you can see we've got rows. What does rows mean?
It means we're separating out an already grouped field and we're then adding file.link. So we want all of the files as rows that have been grouped in some way. And that's going to be called amount. What are we grouping by? Group by t as tags.
What is t? t is the flatten of file e tags. So what this is doing is it's flattening out the files for all of the tags and calling it t. Then it's grouping by that and calling it tags.
So all of the files with example will then be shown as a number because it's been lengthed inside of the amount column. This from is saying look from everywhere but if I remove this it doesn't actually change anything inside of the query and we're looking for where file.e tags. And coming into the documentation, implicit fields, scroll down. File.etags is a list of all explicit tags in the note.
Unlike file tags, does not break sub tags down, i.e. tag 1a blah, blah, blah, blah. So if we come into John, we add a property, we add the tags, we add example and come back to our query. It now says two because we've got John and Danny both with the example tag.
This query also being sorted by that. expression that's being used. So it's lengthening the rows of the file links.
So it's separating out this group by to look for all of the files, lengthening that, so two, and then giving a description. Because if we add a second tag to John Stewart, we now have two tags, and the flatten is giving John two results, one for the example result, one for the second result. It's then being grouped.
So one of John's is in here, and one of John's is in here, and... They've been added together, so Danny and John makes up this up, and John just makes this up. And it's being sorted by that using this expression. So we have second down below, an example at the top.
Now I have deliberately left out DataView.js because JS, those people that understand JavaScript, will probably be able to find the documentation, and those that don't understand JavaScript probably won't need to use it. But Just as an example of things you can do with JavaScript if you're interested, you can see we have the JavaScript reference that works very similar to DataView query language. So you have DataView, JS, but then you can search for anything inside of a code block reference. So you can create tables, create lists, just like the normal DataView query language, but you can query slightly differently.
So the current file is dv.current instead of... this.filename. You can search for all the pages dv.pages instead of just using the from.
And as you can see, there are lots of other additional things you can do with JavaScript alongside writing your own code looking something like this. So what Dovis has done is created constants, which is kind of like literals. They are things that can be used later on in the code.
So time is equal to dv.date of now, which is similar to date brackets today from data view query language. Then created hour which is equal to time dot to format h. So very reminiscent of the flatten lines where you say flatten then the expression then as and then the name.
This is similar but javascript so we're creating a constant of hour and that's equal to this expression or this expression. Then we've got another constant of our word. So this is hour and hour is the constant here.
So time dot to format. And these numbers are literals being added. These are comparators.
So is it bigger than or smaller than? And the question mark and colons are if. So similar to the choice.
If this is true, do true or false. But because we have two next to each other, they are what's called nested if statements, which gives us the text appropriate to the time of day, which is all stored in our word. So we have three constants. Hour being used inside of the hour word calculation. Then hour word and time being constants we can use to show.
And they're going to be shown in the header of one. So it's a one header formatting. We're going to show it's add that to the time to format the time, which is the constant.
And then it's going to be formatted like this with at t at the end. So when we look over here at the render. It's is the word here. It's in a heading one format, which is why it's bigger. We then have the time in the format of CCC.
So there's the day, there's the month, there's the day again, and there's the year. Then we've got at, the word at, and then t, which is the time. So it's currently 1601. It's actually not because I haven't refreshed the data view query, but now it's refreshed to 1610 with the dot at the end. With the next line saying. dv header2, so the format is header2, which is why it's smaller writing, good, added to the hour word, which is this constant, afternoon, colon Danny.
So it's saying good afternoon because it's in the afternoon because that's what the time is. A couple of other points worth considering is inline data view query language can be used. So you can see here you can still use this file and then any sort of literal or function that you can normally use in DQL, the DataView query language, and that relates to this toggle which we turned on, the enable inline JavaScript queries and also the enable inline queries, making sure both of those are toggled on in case you use JavaScript or just the normal DataView language. And then looking at the code block settings you can see the inline query prefix is equals.
So instead of using an entire code block we're going to use inline code which is the same icon but only one of them and then to start data view instead of typing data view we're going to use equals and of course that's then thrown up the error data view inline field error because I don't have anything in there. So now I'm using an inline query looking at this file and then looking for this literal information which is just the file name so example which is why it's now showing Example and it looks like text but when I put the cursor on it it actually shows the inline query And we can use any of the literals so let's just remove this and say Date today because this is a literal and what we need to do is update the query so go into there now It's updated this is today's date you can see I'm recording this after the first session and because this is inline you can put words before it and then after it so now you have essentially a formula or a calculation potentially inside of text which can be very useful then you can also add css so if you go into the settings and we have a look at the appearance tab the themes these files are written in css and what you can do is add it inside of the data view query and because it does require you to understand a different code language or markup or whatever you want to call it I'm not going to go into depth on this, but you can see we've got these speech marks, which essentially say, hey, this is the information. We're going to change the font color and this is the hex code that we're going to change the font color to. Going to add a break.
Then the plus inside of here, we then have the key or property that we want to use. So DOB is the date of birth. And then we want to rename this as DOB. So it says that at the top, otherwise. It would have that at the top, which isn't very nice.
So now I have orange result, which is what this is. And of course, you can then customize that to add in functions and expressions with CSS. So as a verbal example, maybe you say if the date is bigger than three days or five days, make it red.
If it's not, make it green. So you can add in different expressions with colors inside of the data view queries, essentially giving you full flexibility. And let's just give you a couple of examples.
You can make that a three heading as well. So markdown is still kind of involved here as well, which is very extensible. Hopefully that helps you out a bit.
If you have any questions, either go to the Obsidian Discord and go to the DataView channel because there are loads of DataView experts in there, or you can join my server to get some help from me. But obviously that's limited to me. You can ask questions in the comments, but YouTube and comment backwards and forwards is kind of difficult. So be aware of that.