How to include multiple fields in one columns

Hi Obsisidian/Dataview community. Thanks in advance for your help!

I would like to include multiple fields (from YAML) in a single column in a Dataview TABLE.

For example, I have two notes, with YAML fields for either doi or isbn:

I would like to create a table that shows both doi and isbn in the same column called id.

Note that in my current structure, no note will have both doi and isbn so id would always only include one or the other.

I can include doi and isbn as separate columns or a boolean of whether either exists:

However, I’m stumped as to how to get the actual doi and isbn to display in the id column. I’ve tried playing around with Dataview functions but haven’t figured out how to get those working.

Any suggestions would be much appreciated!

2 Likes

You can try this:

```dataview
TABLE title, (doi + ",  " + isbn) as id
FROM "reading"

But there are two “issues”: 1) the separation between the two fields (", " or something else) and 2) the “-” that shows if one of the fields is empty.

Thanks! That works, but as you noted isn’t “pretty”. I’ll use this for now and hold out for other solutions.

Building off your solution and adding a regex replacement, I have another not-so-pretty workaround, which seems to insert escape characters (/):

TABLE  title, doi, isbn, regexreplace((doi + ", " + isbn), "-|,", "") AS id
FROM "reading"

1 Like

I don’t have knowledge in ‘regex’ but that seems interesting.

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