I am trying to find a versatile query to transform blocks into tables.
Given the following block structure
#name
- child-block 1
- grandhchild-block 1
- grandchild-block 2
- child-block 2
- child-block3
- grandchild-block4
- great-grandchild1
- greant-grandchild2
- grandhchild-block5
Can I construct a query that generates a table with the following schema?
table title:#name
| child-block1 |
child-block2 |
childblock3 |
| grandchild-block1 |
grandchild-block3 |
grandchildblock4 - great-grandchild1 - great-grandchild2 |
| granchild-block2 |
“” |
grandchild-block5 |
Essentially
- the child blocks would be treated as table headers.
- the grand-child blocks would be treated as values
- any child below the grand-chilld would be listed as bullet points within the grandchild’s cell
Additionally, if there is a way to append any new properly structured #name block to the table created by the query (instead of having multiple #name tables), that would make for a perfect versatile query to coalesce structured content.
Thank you!
Thank you for your feedback @mentaloid
Complexity
I am aware of it and wondered if I should ask for a the simplest version of my request first. A starting point could be to simply be able to transform
title
- child block1
- child block2
into
| child block2 |
child block2 |
| grandchild block1 |
grandchild block2 |
Usefulness
This query would essentiallty be the complement to templates.
Imagine that you have a template to document your work achievements
#workachievement
- company
- role
- task
- achievement
| Company |
Role |
Task |
Achievement |
| value1 |
value2 |
value3 |
value4 |
or your mood journal
#mood
- today I…
- this made me feel…
- the reason is…
| Today I… |
This made me feel… |
The reason is… |
| value1 |
value2 |
value3 |
or your project ideas
#projectidea
- description
- target problem
- expected benefit
- proposed implementation
| Description |
Target Problem |
Expected Benefit |
Proposed Implementation |
| value1 |
value2 |
value3 |
value4 |
You could copy paste the query in the #workachievement or #mood or #projectidea pages, and, just by changing the target hashtag, get a summary table that would give you an overview of your notes on the topic. Thinking about it, adding the date of the note could make it even more useful.
Properties
I have seen an example about using properties for a table of film reviews, and I am open to a suggestion that would make use of properties.
The reason why I asked for a query that builds on the basic nested writing structure of Logseq is that
- there is a clear, almost natural, relationship between a (shallow) nested block and a table. So converting similarly structured blocks in a table sounds to me like a natural extension of grouping blocks that have the same tag
- Creating properties for each child of each template would lead the a lot of tags that have very little organisational value beyond the creation of the table. Properties are often topic dependent, and a #description pulling blocks from any topic would have little value.
I struggled to make use of your advice as I didn’t have the right mental model for Logseq. But your response was in the back of my mind since you posted it… I recently revamped the way I use Logseq to fit the PARA method, and I now learned use properties much more systematically. To use my previous examples, I document my notes like so:
* note-title:: Successful coordination of an international event
company:: ACME Inc.
role:: Event coordinator
task:: High level description of the work done
achievement:: High level description of the achievement
timeframe:: 2024-04 to 2025-07
tags:: work, eventplanning
* Child blocks to attach more details
* that do not need to appear in the summary tables
And my template for it would look like
* template:: achievements
template-including-parent:: false
* note-title::
* company::
* role::
* task::
* achievement::
* timeframe::
* tags:: work, eventplanning, management, projectcoordination
(I put all the possible tags in my template so I don’t have to remember them: I simply delete the ones I don’t need when invoking it).
All my notes are now actually structured like this, and it’s made creating summary pages a breeze. Sorry for the late response, and thanks for planting the seed @mentaloid! 
1 Like