How do I only display the final “Sub-Folder” in a dataview query. Below is how far I’ve managed to get…
TABLE rows.file.link as "Statute"
FROM "⚖️ Law/Statute/Personal Property Security Act, RSO 1990, c P.10"
WHERE file.name != this.file.name
GROUP BY file.folder AS Section
```dataview
TABLE rows.file.link as "Statute"
FROM "⚖️ Law/Statute/Personal Property Security Act, RSO 1990, c P.10"
WHERE file.name != this.file.name
GROUP BY regexreplace(file.folder, ".*\/([^\/]+)$", "$1") AS Section
```
You’re requiring the / to be present for the regex to kick in, which could have mean’t that first level folders wouldn’t match. But in this case, it’s just returning the unchanged file.folder so no problem.
At regex101.com, you’ve selected to use PCRE regex style (which is for PHP regex), I believe Obsidian is using the ECMAScript variant. Still a minor issue for this regex, but for more complex variants that could make a difference
Other than those very minor thingies, it sure seems to do the trick!