I have a query that looks for all the blocks in the journal, that are not a task, and have a reference to the page where the query is, I want to mark some of the blocks with a tag to hide them from the query (because they become useless to my reports). I have tried a lot of things, but I can’t make the query to filter any block tagged with the #hd … can you give me a hint?
Hey, I’ve just started using logseq and I’m already hooked. This query is exactly what I was missing on the journal page. Only I would like the list to be sorted by scheduled date in descending order and limited to 7d in the future. How can I do that? Thanks for your help.
Thank you very much @Siferiax !! Your post give a lot of value to my Logseq. Appreciate it a lot.
Also, I can read the query better now thay you have rephrase it and clean it.
If you don’t mind, I have an additional question. Is it possible to validate that the child blocks don’t have this tag neither? Do I need to nest the “not” conditions?
But unfortunately, it is not working…
if i add the tag to parent block, it dissapears from the query results with all its children blocks, which is ok; but if I remove the tag from the parent, it is shown in the query results with all the child bullets regardless if the child bullets have the “#hd” tag or not…
You probably see the child bullets as part of the parent block.
They are pulled in, because you see the entirety of the block. That is to say the parent with all children etc.
Say your data is:
parent
child #hd
Then the query will pull parent as part of the result set.
This is then displayed as.
parent
child #hd
Because it is a direct relationship.
Actually now that I think on it.
What you could try is make it a seperate (not )
Though I feel it would stop the parent from being pulled entirely.
But I’m just doing this off the top of my head!
Just know that child blocks are pulled as part of the parent result. I think that is what is happening anyway.
This helped me write my first advanced query. Given a person’s page, it shows all the tasks related to that person. I used query-page so it could go on the right sidebar.
Looking for a query equivalent to {{query (page-property type [[Thing]])}}, though adding a column with respective task counts…
Not being able to make it work because when filtering blocks through markers, the ones that have NO tasks don’t show up.
I wanted to create dashboard for Tasks Pending by count. Although i was able to use Count to get Count by Types but they were not coming in Table Format.
This query groups task by marker and prints count in table format. Can be modified further for your usecase.
#+BEGIN_QUERY
{:title "✅ Count of DOING and LATER Tasks"
:query [:find ?marker (count ?b)
:keys type number
:where
[?b :block/marker ?marker]
[(contains? #{"DOING" "LATER"} ?marker)]
:group-by ?marker]
:view (fn [rows] [:table
[:thead [:tr [:th "Type"] [:th "Count"] ] ]
[:tbody (for [r rows] [:tr
[:td (get-in r [:type])]
[:td (get-in r [:number])]
])
]])
}
#+END_QUERY
Yeah bit of an issue with that. I’ve been trying to do the same, worked on it awhile back.
We are trying to ask the question.
From all blocks on a page, what are the tasks? Then only count those. There is no way to say, but hold up if you don’t have tasks, count 0.
It’s because we get the dataset first and then count. Instead of for example Excel does a count on the data directly.
So because we filter this data, we cannot have a contradiction.
Give me when x is true and when x is not true, would just return everything and you will end up counting all blocks.
Writing this, I’m thinking lol, maybe with a get I’ll have to explore that train of thought later.
Hi all, this is awesome thanks! I’ve been doing some research on datalog and logseq quries, but I haven’t been able to include restrictions on time when the query is executed. I would like to see, for instance, my home tasks everyday at 4pm only, and not before that. Is it possible to build a query that excutes its task only if the time is past 4pm, and before 6am ?