List frontmatter properties of child notes linked from parent note frontmatter

What I’m trying to do

I am trying to use Obsidian as an electronic notebook for chemistry experiments. Here is the proposed workflow:

I have a series of files, one for each chemical, in a folder called “Chemical Database”. In the frontmatter of these files is a list property called “H Phrases”, where the hazard phrases of the chemical are listed.

For each experiment I would create a new note in a folder called “Lab Book”. In the frontmatter of each experiment, I would have a list property called “Chemicals”, in which the chemicals used in that experiment are linked.

What I would like to happen is for the “H Phrases” from the chemical file to be pulled into a dataview table within the experiment.

Things I have tried

I currently have the following working:

```dataview
Table H_Phrase
from "Chemical database" and outgoing([[0007, DCC coupling]]) 
```

However, the H_Phrase column contains blanks, and the outgoing() requires me to input the note title rather than automatically using the current note title, so I couldn’t add this to my template.

Any help on how to improve this solution or alternative ideas would be much appreciated.

One other option, which I do not know how to implement, would be to list all the “H Phrases” in the first column then in the second column all the Chemical names that have this phrase. If you have any thoughts on how to do this too, that would be great.

Thanks!

To reference links in the current note, you would do:
FROM "Chemical database" and outgoing([[#]])

However, your method looks through all links in the experiment and returns all linked chemicals, including a chemical you link to while taking notes or link to in a different property. For a more efficient query and to free up the rest of your content to link at will, go with:

```dataview
TABLE H_Phrase
WHERE contains(this.Chemicals, file.link)
```

The query doesn’t add null values on its own. Open your chemical note, view it in source mode, and check whether you have any extra lines or nonstandard syntax in the H_Phrase value. For example, the second item in this list is null and would be represented by a dash in the table:

---
H_Phrase:
  - "H319: Causes serious eye irritation"
  - 
---

To list H Phrases and chemicals in the experiment:

```dataview
TABLE rows.file.name AS Chemicals
FROM "Chemical database"
FLATTEN H_Phrase
WHERE contains(this.Chemicals, file.link)
GROUP BY H_Phrase AS "Hazard Phrase"
```

To list H Phrases and chemicals in the “Chemical database” folder (you could put this query in any note):

```dataview
TABLE rows.file.name AS Chemicals
FROM "Chemical database"
FLATTEN H_Phrase
GROUP BY H_Phrase AS "Hazard Phrase"
```
1 Like

Wow this is great, thank you!

I checked back and yes, there were null values on those chemical pages for some reason.

This table is pretty much exactly what I was looking for. I’m pretty new to dataview so this may be obvious, but is there a way to: (a) remove the bullet points (b) order/group the H_Phrases, e.g. ascending order grouped by H2XX, H3XX, H4XX?

This one is also great! Is there a way to (a) make the Chemicals links to their respective pages, as with the previous example, (b) remove the bullet points as with the previous, (c) apply a grouping to the H_Phrases as with the previous example, e.g. ascending order grouped by H2XX, H3XX, H4XX?

I really appreciate your help, do you have any recommended resources for learning how to make dataview queries? I would like to be able to change the visual appearance of the tables too, e.g. alternating highlighted rows, bold colour for specific high hazard H_Phrases like the ones with “fatal” in them.

Thanks!

Remove bullet points + ascending order

You just need to edit @dawni code slightly. This will make the bullets disappear, sort your table in alphabetical order and your H_Phrase entries in ascending order.

```dataview
TABLE join(sort(H_Phrase), "<br>") AS H_Phrase
WHERE contains(this.Chemicals, file.link)
SORT file.name ASC
```

Additional info

If you decide to use the Minimal theme, I think the bullets are hidden by default. Bonus: you could also use a helper class to highlight every other row.

---
cssclasses:
  - row-alt
---

Regarding dataview resources, check the documentation. Just search for what you need when you need it and you’ll learn little by little. I don’t create queries often enough to memorize everything, so I often check the doc and/or ask an AI, then make some tweaks until I’m satisfied. To change the visual appearance of the tables, I would use some css snippets, but there might be plugins.

Table appearance

I would probably use some CSS and dataviewjs to change the visuals but for simple stuff, you can do this:

```dataview
TABLE join(sort(regexreplace(
	H_Phrase, "(H2|H3)", "<span style='color:orange; 
	font-weight:bold;'>$1</span>")), "<br>"
) AS H_Phrase

WHERE contains(this.Chemicals, file.link)
SORT file.name ASC
```