Dataview: Create new row for multiple-value field

Hi, I’m stuck with a dataview-problem. I’m trying to achieve the following:

In each note I’ve a header that looks like so (example):

---
type: idea
status: done
reference: Genesis 19; Genesis 18; Luke 24
---

I’m now trying to get a TABLE that lists me all the bible references in an overview. I want each reference to be a seperate row, along with the related notes in the second cell. So this is what I’m aiming for:

REFERENCE      |  NOTES
---------------------------
Genesis 19     | Note 3
----------------------------
Matthew 24     | Note 1
                 Note 4
                 Note7
---------------------------
Revelation 2   | Note 5
                 Note 7

So far I only get it managed to become a Table with all Notes and the according references in the same line (as a new line, but in one Cell)

TABLE replace(reference, ";", "<br>") as Reference
FROM "my notes"
WHERE bibelstellen

Gets me something like this:

FILE        |  REFERENCE
---------------------------
Note 1      | Genesis 18
              Matthew 24
              Luke 18
----------------------------
Note 2      | Genesis 19
---------------------------
Note 3      | Revelation 2

Is there any way to achieve this? Thanks for any ideas!

2 Likes

Ok, I managed something “okay” for my usecase, but it’s not quite there yet.

TABLE WITHOUT ID reference AS "Reference", file.link AS "Note"
FROM "my notes"
WHERE reference
FLATTEN reference
SORT reference

I get all the references in Column 1 with the according notes in column 2. Each reference is a new row, and duplicates are shown.

BUT: As soon as I add the “Group” syntax in the code like so:

TABLE WITHOUT ID reference AS "Reference", file.link AS "Note"
FROM "my notes"
WHERE reference
FLATTEN reference
GROUP BY reference
SORT reference

The Notes column only shows “-” . My actual goal would be to show every note with that reference in the cell. But that doesn’t happen.

Maybe it’s only possible to accomplish with dataviewJS, but I’m not familiar with it.

Every time you introduce GROUP BY your fields get gathered into rows.*, and the grouping expression into key.

So in your case you should be able to use either of the following lines as the first line in you query (but just one of them :slight_smile: ):

TABLE WITHOUT ID key AS "Reference", rows.file.link AS "Note"
TABLE rows.file.link AS "Note"
1 Like
TABLE WITHOUT ID key AS "Reference", rows.file.link AS "Note"
TABLE rows.file.link AS "Note"

Thanks a lot, that did it! Great :slight_smile: Learning every day.

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