I have a global tags database; within that database, I have the properties: "Tag Name"- title property, "Parent Tag"- Relation to this database, "Sub-Tag"- Relation to this database, "Description"- Text property, "Sub-tags Count"- Formula property, "Unformatted Sub-tags Count"- Rollup, then I have relations to my Documents, Notes, and Notebooks databases. I am looking for a formula that will auto-generate the full path of each tag, with its complete hierarchical path, into a formula property called "Full Path (Auto). Example: For a child tag "Nutrition" under "Health," which is under "Areas of Life," the Full Path would be "Areas of Life/Health/Nutrition." This way, when tagging an item in another database, I can search the relation property by any part of the tag's path; if I search the parent tag name, it will show all its child tags. Can anyone help me out with a formula to do this?
Connect
Notion Answers
Help between Notion users
Register & Ask
It's free & easy
Get answers
Answers, votes & comments
Vote and select answers
Receive points, vote and give the solution
Question
2 Answers
Without seeing the complete structure is difficult to tell, but you can try calling the properties and formatting them to text with something like this.
"Areas of " + format(prop("One")+"/"+prop("Two")+"/"+prop("Three"))
That Notion formula is just calling and formatting to text the properties One, Two and Three + the needed text.
You will need to adjust it to your properties names and extend it with some "if" scenarios where there is nothing in the property.
Hope that helps.
Hey there! I've been training my own AI model on all the Notion formula information available on the internet and it suggested this answer to your formula puzzle.
If you're interested in trying it out yourself, please let me know.
Model Reply Below:
I'll help you create a formula for generating the full hierarchical path of tags in Notion. Let's solve this step by step.
First, we need to consider that:
- We need to get the parent tag's name recursively
- We need to handle cases where there might be no parent tag
- We want to join the path components with "/"
- We need to handle potential empty states
Here's the formula solution:
/* First get parent tag info if it exists */
let(
parent_path,
if(
empty(prop("Parent Tag")),
"",
prop("Parent Tag").map(current["Tag Name"]).join("")
),
/* Then combine with current tag name */
if(
empty(parent_path),
prop("Tag Name"), /* If no parent, just use current tag name */
parent_path + "/" + prop("Tag Name") /* Otherwise join with slash */
)
)
Let's break down how this works:
-
We use
let()
to store the parent path calculation for clarity and efficiency -
For the parent path:
- Check if there's a parent tag using
empty(prop("Parent Tag"))
- If no parent, return empty string
- If there is a parent, get its Tag Name using
prop("Parent Tag").map(current["Tag Name"])
- The
.join("")
combines in case there are multiple parents (though typically there should be only one)
- Check if there's a parent tag using
- For the final combination:
- If parent_path is empty, just return the current tag's name
- Otherwise, combine parent_path + "/" + current tag name
This will generate paths like:
- "Areas of Life/Health/Nutrition"
- "Areas of Life/Health"
- "Areas of Life"
Some important notes:
-
Make sure your property names match exactly:
- "Tag Name" for the title property
- "Parent Tag" for the relation property
-
This formula assumes a single parent per tag. If you have multiple parents, you might want to modify the formula to handle that case.
- You should create this as a Formula property named "Full Path (Auto)"
If you want to make it even more robust, here's an enhanced version that handles more edge cases:
/* Enhanced version with better error handling */
let(
parent_path,
if(
empty(prop("Parent Tag")),
"",
prop("Parent Tag")
.filter(!empty(current["Tag Name"])) /* Filter out any empty names */
.map(current["Tag Name"])
.join("/") /* Join multiple parents with slash if they exist */
),
/* Combine with current tag name, handling empty current tag case */
if(
empty(prop("Tag Name")),
"Unnamed Tag", /* Default value for empty tags */
if(
empty(parent_path),
prop("Tag Name"),
parent_path + "/" + prop("Tag Name")
)
)
)
This enhanced version:
- Filters out any empty tag names in the parent chain
- Handles the case where the current tag name might be empty
- Uses a more robust joining strategy for multiple parents (if they exist)
You can then use this "Full Path (Auto)" property in your relations to other databases, and as you mentioned, searching for any part of the path will help you find the relevant tags.
For optimal performance, ensure that:
- Your parent-child relationships don't create circular references
- Tags have unique names within their hierarchical level
- The Parent Tag relation is properly maintained
Related questions
- A separate Areas of Life database or a multi-select property in each of the databases I want to see on the dashboards
- Need help to make progress that will be responsive to Status in second database
- How I can auto fill a data base with consecutive numbers (just like in Excel when you pull down)
- How can I wrap/split a line of customized text within the formula?
- How do I created a status formula based on the status/presence of multiple variables?
Without Answer
-
- 18
- 0
- 8 hours ago
-
- 85
- 2
- 6 days ago
-
- 74
- 0
- Jan 30
-
- 107
- 1
- Jan 23
-
- 115
- 0
- Jan 16
-
- 97
- 0
- Jan 15
-
- 130
- 1
- Jan 6
-
- 93
- 1
- Dec 30, 2024
- see all
Exclusive for Notion Answers Users
- • Dynamic Calendar Icon | Info | Download
- Add yours here
Recent Activities
aliry asked 8 hours ago
Using a bar chart, can I divide each bar into perc…notionbackups answered 1 day ago
Where does notion keep my data?sydann04 commented 4 days ago
Created Views Not Showing in Linked Databasethomas_yang commented 4 days ago
Created Views Not Showing in Linked Databasesydann04 asked 5 days ago
Created Views Not Showing in Linked Database