Show Only Subtags in Bases Table?

What I’m trying to do

I have a set of notes with tags of the form Tag/Subtag. I’m preparing a Bases table view and would love to only see the associated ‘Subtag’ in a “tags” column.

Things I have tried

I’ve searched the forum and found some custom CSS for dataview, but am unsure if this can be incorporated into Bases at present.

Create a formula e.g.: list(tags)[0].split("/")[1]

1 Like

I haven’t tested this yet but WhiteNoise mentioned

file.hasTag() is the solution regarding supporting nested tags in bases.

You’ll be able to search for parent tag in frontmatter-only tags with tags.filter(value.startsWith('parent'))

1 Like

Is there any way this can be expanded to handle items with more than 1 tag? I noticed it works great if something only has Tag/Subtag, but if it has Tag/Subtag and another Tag/Subtag, only the first result is returned.

As far as I can tell, this is useful for applying a Filter but I am trying to display the relevant tags as a Property so I’m not sure how this helps? I might be missing something though!

There are a lot of possible variations depending on your setup and what you want to display. This formula drops the first parent of all the tags:

tags.map(value.split("/").slice(1)).flat()

You can use join() to add a symbol of your choice between the child tags, such as:

tags.map(value.split("/").slice(1)).join(", ")

Or do a variation on those to get the display you want.

1 Like

This is perfect, thank you so much! I haven’t used JavaScript much, so didn’t know the proper syntax to chain the formulas together.

1 Like

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