I’m really glad to hear it helped!
Thank you for getting me to finally figure out how group by
works
I tried a hacky method which didn’t seem to work.
I thought to use length()
or sum()
, but each of these only works as a test in a where
block; it doesn’t give a returnable value.
I think this would be really useful though. Check if it’s an existing feature request and give it an upvote, otherwise make a new post for it
For now, you could totally pair dataview with the Obsidian Query Language plugin (OQL).
After your dataview table/list, put an OQL codeblock underneath it to show the {count}
of the same query.
Source
Thanks a lot for your help.
I also tried to play with Group By
and ‘sum’ and ‘length’ functions but like you said, it doesn’t seems to work in this context.
I thought that OQL’s queries only rely on folders… I will check the doc again to see if it works also with yaml frontmatter metadata.
I haven’t used OQL very much, so its definitely possible that it doesn’t allow querying on the same objects as dataview.
But I think this would be a useful feature to request in a future update
So your post got me thinking alot, and I think I’ve figured out a workaround for seeing how many results get returned!
This CSS snippet will number the rows of a dataview table:
.table-view-table {
counter-reset: section;
}
.table-view-table > tbody > tr > td:first-child::before {
counter-increment: section;
content: counter(section) ". ";
}
Resulting in something like this when you make a table:
Wow, I’m silly.
Maybe it had something to do with how it appears queries are cached, so I may have made an update to a nested tag and expected a result to automatically appear which I now see isn’t the case (and totally understandable).
Simple oversight, thank you for responding
Nice solution, but are you sure it is correct? I tried it and it just gives number 1 to all the items on the table.
You can get the value using length()
; I got the number of files tagged #Ticket
like so:
TABLE length(rows) as ticketCount
FROM #Ticket
GROUP BY true
It was a little tricky to figure out the summing, but I got that as well. Here’s what I use to see how many points I’ve accumulated in my #Tickets for the current Sprint, as well as how many more I need to hit my current goal of 10:
TABLE sum(rows.Points) as TotalEarnedPoints, 10-sum(rows.Points) as PointsToGo
FROM #Ticket and [[Sprint Ending 2021-04-08]]
WHERE Ended != null
GROUP BY Sprint
Huh, I mean its still working for me. What theme are you using? Did you add it to the main.css, or as a snippet?
So it’s definitely targeting the right element if you see the numbers in the right place. But it seems its not incrementing the value properly. That’s what the counter-increment: section;
is for.
Nice! I was missing the fact that you have to give the length(rows)
value an alias! as whatever
.
I also like the summing method, good catch
I am using it as a snippet, I am using Minimal theme with some other snippets from here:
yeah , it is definitely doing something right. or maybe it is because one of the plugins , it is hard to tell
You can use this CSS snippet to add lines to the rows of table view:
.table-view-table tr {
border-bottom: 1px solid;
}
For something like this:
As opposed to this:
I’m not sure, hey. I don’t know much about CSS or the interaction with other plugins… Could you see if it works in Safe-mode? You would have to manually re-enable all your plugins afterwards, though
I’m loving this dataview plugin. Automated lists makes it that much closer for obsidian to use as my primary PKM.
I’m a massage therapist and I’m experimenting with Obsidian. I use special tests to narrow down potential causes for pain and dysfunction. At the top of each test, I can have some information about the test for the automated list.
—
type: test
location: [shoulder, cervical]
dysfunction: [spaceoccupy, compression]
—
Now in my automated list I’d have code - lets say it’s my shoulder list…
table dysfunction from ""
where type = "test" AND location = "shoulder"
It doesn’t pick up on this test, I’m assuming, because the location is not just the shoulder.
I’ve seen a solution something like
table dysfunction from ""
where type = "test" AND location[0] = "shoulder"
but this only works if shoulder is the first item. I’d need it to work regardless of which position shoulder is listed.
I’m not a programmer (I dabble in css and html, I repeat myself), so I’m sure I’m just missing something simple. Any help would be appreciated
Random long shot but try the contains
function. It’s in the data view docs under object functions.
Not sure if it would work in this case but it may since that is a list object.
The syntax would look something like this:
where type = "test" and contains(location, "shoulder")
But don’t quote me on that being exactly the correct syntax.
Is it possible to have Dataview display a different string if a calculated field satisfies some condition? For example, if my calculated “days-left” field is less than or equal to 1, I want to display a warning emoji. I’m not sure if control logic like that is possible.
Btw, how do you guys use emojis? Do you memorize alt-code for each one or what?
I personally use the Emoji Toolbar plugin But on Windows you can also press Win + .
to bring up an emoji keyboard
Yup, this should work
As per the docs, contains
works on lists like this: contains(list(1, 2, 3), 3) = true