I’m trying to create a Dataview query that produces index of recipes sorted by the YAML property “meal” (which contains values like “bread”, “breakfast” or “dessert”.
I’m trying to do something like u/mnvwvnm does here:
However, first column of mnvwvnm’s table is based on tags, and (as I said) I want one based on the YAML field “meal”.
Things I have tried
I can almost get what I want with this query:
TABLE WITHOUT ID
meal as "Meal",
file.link AS "Recipe"
From [[Recipes]]
SORT meal asc
However, this query lists the meal in every row, whereas I’d like it if the meal (e.g. “bread”) appeared once, like the tags do in the index mnvwvnm creates.
I’ve tried using GROUP BY, like this:
TABLE WITHOUT ID
meal as "Meal",
file.link AS "Recipe"
From [[Recipes]]
GROUP BY meal
But all that does is list my five (current) meal types, and with each one the “Recipe” column is just “-”.
Thanks for the reply, unfortunately I don’t think that’s quite what I’m looking for.
All my recipes have the property “meal” which either has the values “bread”, “breakfast”, “dessert”, “main” or “sauce”, because these are the types of recipes I have.
With my current formula (above) I get a result like this:
But in mnvwvnm’s tag-based index (link above) each tag only appears once, followed by a list of the relevant notes (so there’s no column bread, bread, bread…)
I could achieve my goal by copying his index and just using tags to specify the “meal” for each recipe, but I’m hoping it’s possible to GROUP BY meal.
However, when I add GROUP BY meal, I just get a result like this:
I did some more searching and finally found an answer on this post:
The query that has achieved my goal is:
TABLE WITHOUT ID
meal AS Meal,
rows.file.link AS Recipe
FROM [[Recipes]]
FLATTEN meal
FLATTEN link(file.link, Title) AS Note
SORT meal ASC
GROUP BY meal