Bases: contructing link to file, based on YAML values

I am writing a story and have it cut up in parts, chapters and scenes. I have a file for every type, defined in YAML by type.

My Scene-YAML is:

---
type:
  - scene
title: Sample Scene Title
part: 1
chapter: 2
scene: 1
---

My Chapter-YAML is:

---
type:
- chapter
part: 1
chapter: 2
scene: 0
title: Sample Chapter Title
---

Now I want to create a Base-file, where I list all the scenes, but add a column with the corresponding chapter title.

So it should filter on:

  • type contains chapter
  • part from scene-file == part from chapter-file
  • chapter from scene-file == chapter from chapter-file

And then show the title from the chapter-file.

How can I manage this?

If I understand correctly what you want, I don’t think this is possible. You basically want to filter all files in your vault within a bases formula, and to my knowledge, that isn’t supported by any function.

You would need some way for the files to already be linked in order to obtain the path of the chapter file, or your chapter filenames would need to be constructable from the properties of the scene notes (for example: examplePath/knownText/part/chapter).

Are there any links between chapter and scene files?

EDIT: If linked, something like this would be possible:

You can do it with links, as Zodian explained. For example…

  • cool scene.md

    type:
      - scene
    chapter: "[[cool chapter]]"
    scene: 1
    title: Cool Scene
    
  • cool chapter.md

    type:
      - chapter
    part: "[[cool part]]"
    chapter: 2
    title: Cool Chapter
    

But if you don’t want to change your properties to hold links, you could modify your concept of the base to one that simply returns all your chapters and scenes grouped by act-chapter numbers and sorted by scene number. For example:

```base
filters:
  and:
    - type.containsAny("chapter", "scene")
formulas:
  group: '["part", part, "chapter", chapter]'
views:
  - type: table
    name: Table
    groupBy:
      property: formula.group
      direction: ASC
    order:
      - file.name
      - scene
      - title
    sort:
      - property: scene
        direction: ASC

```