Create a table with an array of tags

Things I have tried

I searched a lot of dataview related topics. Found out about converting a string date to an actual ISO date, or else you can’t do calculations with it.

Found a couple of topics that came close to what I try to achieve:

What I’m trying to do

I have one note with all the requirements for a school project. Every topic in this note has its own deliverables and due date. I use inline tags to mark those deliverables with a date and tag.

Something like this:

Deliverable 1
[duedate:: 2022-11-22]
[duetopic:: “Paper about deliverable 1”]
Lorum ipsum something something dark side something something dark side.

Deliverable 2
[duedate:: 2023-01-13]
[duetopic:: “Paper about deliverable 2”
I like turtles. Here’s my presentation about turtles.

Deliverable 3
[duedate:: 2022-12-11]
[duetopic:: “Another paper that drives me nuts”
So many papers to write, review and evaluate.

My DQL

TABLE
	duetopic AS "Subject", 
	duedate AS "Due date",
	date(duedate) - date(today) AS "Days left"
WHERE
	contains(tags, duetopic) and
	contains(tags, duedate)
FLATTEN 
	duedate
SORT
	duedate ASC

This works. I get a nice table and I can see how many days left until I complete stress out for my deliverable. But the table repeats every subject:

File Subject Due date Days left
[[mynote]]
  • Paper about deliverable 1
  • Paper about deliverable 2
  • Another paper that drives me nuts
  • 2022-11-22 1 week
    [[mynote]]
  • Paper about deliverable 1
  • Paper about deliverable 2
  • Another paper that drives me nuts
  • 2022-12-11 1 month, 5 days
    [[mynote]]
  • Paper about deliverable 1
  • Paper about deliverable 2
  • Another paper that drives me nuts
  • 2023-01-13 2 months, 1 week, 3 days

    But what I try to achieve is this:

    File Subject Due date Days left
    [[mynote]] Paper about deliverable 1 2022-11-22 1 week
    [[mynote]] Paper about deliverable 2 2022-12-11 1 month, 5 days
    [[mynote]] Another paper that drives me nuts 2023-01-13 2 months, 1 week, 3 days

    I had to flatten the duedate or else the same list appeared for the dates as well.

    How can I achieve a table with one row per deliverable, containing the topic and the due date, where all the tags come from one and the same note?

    Many, many thanks in advance!

    1 Like

    First error: don’t call it inline tags! They’re not tags, they’re inline fields. Tags in Obsidian are other thing: #tag. Not only a syntax error because you really think they’re tags - WHERE contains(tags, duetopic)!

    Second point: I’already explained this in help Forum multiple times (:slight_smile: ) the error of thinking in the metadata as “pseudo-groups”!

    Taking your example, the available metadata extracted from your inline fields is collected in this way:

    duedate:
      - 2022-11-22
      - 2023-01-13
      - 2022-12-11
    
    duetopic:
      - Paper about deliverable 1
      - Paper about deliverable 2
      - Another paper that drives me nuts
    

    As you can see, there’s no direct relation between fields (only the order).
    That’s why when you flatten the list of values in duedate, each value takes with him all the values in duetopic.

    1 Like

    Let’s say you use instead this format (using list items, under a specific header/section - because in lists there’s a metadata relation to headers):

    ## Deliverable 1  
    - duedate:: 2022-11-22
    - duetopic:: Paper about deliverable 1
    
    Lorum ipsum something something dark side something something dark side.
    
    ## Deliverable 2  
    - duedate:: 2023-01-13
    - duetopic:: Paper about deliverable 2
    
    I like turtles. Here’s my presentation about turtles.
    
    ## Deliverable 3  
    - duedate:: 2022-12-11
    - duetopic:: Another paper that drives me nuts
    
    So many papers to write, review and evaluate.
    
    

    An this query:

    TABLE WITHOUT ID
    	key AS "Deliverable",
    	filter(rows.L, (r) => r.duetopic).duetopic AS "Topic",
    	dateformat(filter(rows.L, (r) => r.duedate).duedate, "yyyy-MM-dd") AS "Due Date",
    	(filter(rows.L, (r) => r.duedate).duedate[0] - date(today)).days AS "Days left"
    WHERE duedate AND duetopic
    FLATTEN file.lists AS L
    WHERE L.duedate OR L.duetopic
    GROUP BY meta(L.section).subpath
    SORT rows.L.duedate ASC
    

    4 Likes

    I am very grateful for your help and willing to help for what seems to be very futile
    questions. I see your name in almost all the topics I searched in. A legend among Obsidians (is that what we call ourselves? :slight_smile:).

    Thank you for all your effort you put in to help people of all skill levels.

    I read your logic and explanation and I feel so stupid for not seeing it myself. You are absolutely right about the tags and fields mixup. My problem is often that I overthink basic logic too much.

    Now the DQL is something I have to read a couple of times and untwine your logic as JS is something I try to learn more and more using Obsidian. Working from inside the parenthesis outwards, I think I get what you do.

    Using your query I got exactly what I wanted, and more! I am very grateful and helped.

    Maybe one question if you allow me, how did you remove the bulletpoints for the list items? In your screenshot I don’t see bulletpoints. I guess that’s CSS?

    Dataview requires a long curve learning (an endless curve, I guess). So, it’s necessary to ensure some solid steps at the begining.
    But this isn’t a query to that. It involves some complexity. It’s a query to solve a specific case,not a good example to learn.

    About the removed bullet points, that is related with the theme I use: Minimal theme. With this theme the lists inside a table don’t have bullet points (well, only “parent” lists). If you use another theme, I guess you can try to search inside the Minimal css code the part related with tables/dataview.

    2 Likes

    This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.