J’ai un défi dans obsidian, j’ai essayé mais n’y suis pas arrivé.
J’espère pouvoir clairement expliquer ce que je voudrais réaliser.
Je vous donne un cas concret:
J’ai 5 listes avec 10 cases à cocher dans chaque listes:
-Liste 1
-liste 2
-Liste 3
-Liste 4
-Liste 5
Dans la liste 1 je coche 3 cases à cocher
Dans la liste 2 je coche 1 case à cocher
Dans la liste 3 je coche 7 cases à cocher
Dans la liste 4 je coche 4 cases à cocher
Dans la liste 5 je coche 1 case à cocher
Ensuite dans un nouveau tableau, je voudrais
classer le nom des listes du dessus dans l’ordre descendant
en fonction du nombre de lignes cochées dans chaque tableaux.
Dans le cas concret cela donne:
Liste 3
Liste 4
Liste 1
Liste 2
Liste 5
Voilà,
merci infiniment de votre réponse
Good morning,
I have a challenge in obsidian, I tried but couldn’t do it.
I hope I can clearly explain what I would like to achieve.
I’ll give you a concrete case:
I have 5 lists with 10 checkboxes in each list:
-List 1
-list 2
-List 3
-List 4
-List 5
In list 1 I check 3 check boxes
In list 2 I check 1 check box
In list 3 I check 7 check boxes
In list 4 I check 4 check boxes
In list 5 I check 1 check box
Then in a new table, I would like
sort the names of the lists above in descending order
depending on the number of lines checked in each table.
In the concrete case this gives:
List 3
List 4
List 1
List 2
List 5
You can’t use the tag since that’s connected to the page, and not any of the sections or lists. The lists are connected to the sections so those can be used in combination with GROUP BY.
I’m a little busy right now, but I can write you an example query in a few hours (I hope).
I took some time, but here is a working example where I copied all your tasks into a given note, and added the query at the end (so you’ll need to adapt the WHERE to match your FROM/WHERE combination.
```dataview
TABLE completedCount, completedTasks.text
WHERE file = this.file
FLATTEN file.tasks as task
FLATTEN meta(task.section).subpath as header
GROUP BY header
FLATTEN list(filter(rows.task, (t) => t.completed)) as completedTasks
FLATTEN length(completedTasks) as completedCount
SORT completedCount desc
```
This query with the example data from above (and some slight modification as to what was crossed out, it then gave this output:
My tasks gets added the completion date, so sorry for that “noise”, and I included a column in the table with which tasks was actually completed. Similar list could of course also be built for the non-completed tasks, if you so want. Then just use !t.completed instead.
Hope this gives you enough information to adapt into your likings. The trick to the query is using the filter() to pull out the completed tasks, and using meta(task.section).subpath to pull the header for a given tasks, and then grouping on that information.
Do note, that after we’ve done the GROUP BY all the data are now collated into lists within the rows object, and the group by expression is stored in the key (which is automatically used as the first column).