I’ve got a note with lots of yaml properties. A section of them are checkbox types, so end up with values of TRUE or FALSE.
I would like to make a table in the body of the note that compares the notes by which properties they have that are TRUE.
Example
I’ve got a note for each planet in my ttrpg worldbuilding. Each has a set of properties that indicate whether they have a specific resource (hasMinerals: ; hasLabor: ( ); hasExoticTech: and so on).
I want a table that lists out the planets, showing the properties that are only TRUE for each planet (key thing is that it lists out the names of the properties and not the values of TRUE).
Things I have tried
I have been doing a lot of trial and error using “filter” and “extract” commands, but they either give me the values of TRUE and not the matching property names, or they show all the info but without filtering out the FALSE ones.
Hi @ahmaddialdin ,
Let’s assume we have notes named planet1, planet2, planet3. Each of these notes contains the following properties in the frontmatter section:
---
hasMinerals:
hasLabor:
hasExoticTech:
---
Planets in notes have the following settings:
Planet1
hasMinerals: true
hasLabor:
hasExoticTech: true
So how would i extrapolate that for all the properties? Using your example, I want it to show me that planet1 has minerals and exotic tech, planet 2 has labor, and 3 has labor and minerals.
I’m getting lost in how to have it check against all properties and show the different true ones for each.
As an example of what I was trying to achieve, here’s the closest to what I’ve been able to pull off.
By doing this:
TABLE WITHOUT ID
file.link as “Planet”,
filter([hasSystem, hasLocation, hasHabitability, hasMinerals, hasExoticFloraFauna, hasLabor, hasExoticTech, hasRuins], (x) => x=true) as “Filter”
FROM (“path to folder”)
It’s showing me all the TRUE values (knowing that they’re different for each planet… e.g. Mihwar hasMinerals, but Xenia hasLabor), but it’s not showing the names of the properties themselves.
Here are some untested code showing the gist of how I would approach this:
```dataview
TABLE WITHOUT ID
file.link as “Planet”,
join(list(
choice(hasSystem, "System", ""),
choice(hasHabitability, "Habitat", ""),
choice(hasLocation, "Location", ""),
choice(hasExoticTech, "Exotic Tech", "")
), ", ") as Resources
FROM (“*path to folder*”)
```
This way you can divide and conquer the presentation of the various resources any way you like. Maybe you would like resources related to survival in one last, and more of a social nature in another, or similar. It also allows for different wording of the field vs presentation.
Your timing is uncanny… I had just finished testing out an array version of that (basically sans join function):
TABLE WITHOUT ID
file.link as Planet,
nonnull(list(
choice(hasSystem, "System", null),
choice(hasLocation, "Location", null),
choice(hasExoticTech, "Exotic Tech", null),
choice(hasRuins, "Ruins", null)
)) as Resources
FROM *path to folder*
So I love having both options working… thanks to both of you for the quick and awesome problem-solving session today. Feels great that I learned how to manipulate dataview from what you guys showed me. Totally appreciate it!