Need some help with data capture and then query using dataview (Explained in post)

Things I have tried

Hi All,
Appreciate some suggestion on the data capture process for my workout log. What I am trying to do is capturing the progression I am making on a weekly basis. I have a daily note setup from a template where i have listed all the exercises. Please see the format I am using to capture my workouts daily.

I am using this format so that i can fold unfold the part which is not scheduled for that day.

I know i am making a mistake by capturing data this way, however this is what I need. Please see the query that I have used which is fetching 0 results.

TABLE WITHOUT ID Progression-week AS "Week", Muscle-group AS "Muscle group", Exercise AS "Exercise name" FROM "03. Daily Notes" WHERE Progression-week >= 1 AND Muscle-group = Chest
FLATTEN Exercise

What I’m trying to do

What I need is a query which will show my progression over the weeks for a particular muscle-group.
So something like this (1st line is the header, have used comma to denote the table below)
Progression-week, Muscle-group, Exercise, Weight(In kgs), Reps, Sets
1, Chest, Bench press, 10, 10, 4
1, Chest, Incline bench press, 10, 8, 4

OR

Progression-week, Muscle-group, Exercise, Weight(In kgs), Reps, Sets
1, Chest, Bench press, 10, 10, 4
2, Chest, Bench press, 10, 8, 4

I believe the issue is with the way i am capturing the data and hence the query above is not able to fetch the data. Could you kindly suggest an alternative way of capturing the workout? Many thanks in advance

Regards,
Prague

Hi.
I have many things to say, but I’m not sure if they’re important.
Why? Because sometimes, before discuss a specific case, we need to know how the tool works. I.e., we need to know how dataview works to think in the best way to structure our notes. (not the inverse) :slight_smile:

Metadata works in page-level (not in pseudo-groups).
If I look to your screenshot, your page metadata is similar to this:

Progression-week:
  - 1
Muscle-group:
  - Chest
  - Shoulder
Exercise:
  - Bench press
  - Incline bench press
  - Decline bench press
  - Incline dumbbell fly
  - Decline dumbbell fly
  - Overhead press
  - Arnold press
  - Dumbbell front raise
Weight:
  - 10
  - 10
  - 10
  - 5
Reps:
  - 10
  - 8
  - 8
  - 10
Sets:
  - 4
  - 4
  - 4
  - 4
  - 4
...

As you can see, in page-level there’s no groups, only fields with a list/array of values. There’s no direct relation between, for example, the second value in Weight and the second value in Reps (only the apparent order, but if you sort one field, the other remains as before).
So, your “false” groups don’t exist at metadata level.
The main question is on the way you structure your note.

Just another point: as you can see in my metadata list above, Muscle-group is a list of multiple values. So, you can’t use Where ... Muscle-group = Chest, because Muscle-group isn’t EQUAL to Chest (contains “Chest”, what is different).

1 Like

Thank you so much for your detailed response. I kind of new that the structure was incorrect and that the nested grouping will not work, and thanks for confirming that.
Please if I may ask, what do you think the structure should look like? Thank you again for your time.

Regards,
Prague

Well, there’s no easy answer to your case.
The main problems are:

  • many fields;
  • the logic of groups/nested fields;
  • inline fields instead of yaml frontmatter fields.

I can suggest a weird solution (simplified) using simple inline fields and avoiding the logic of nested fields. But it’s less intuitive, require a rigorous way in the input of information and implies a “verbose” query (or better, queries separated by “Muscle groups”.

I’m not sure if you place the information in daily note or in weekly note (not clear in your post). Ignoring this, this is an example of the metadata input format:

# My note 1

## Fitness
### Chest
Chest:: Bench press | 30kg | 8x | 3 sets
Chest:: Incline bench press | 20kg | 5x | 3 sets
Chest:: Decline bench press | 18kg | 10x | 4 sets
### Shoulder
Shoulder:: Overhead press | 12kg | 10x | 3 sets
Shoulder:: Arnold press |  |  | 

---

# My note2

## Fitness
### Chest
Chest:: Bench press | 30kg | 10x | 3 sets
Chest:: Incline bench press | 25kg | 5x | 3 sets
Chest:: Decline bench press | 20kg | 8x | 4 sets
### Shoulder
Shoulder:: Overhead press | 15kg | 10x | 3 sets
Shoulder:: Arnold press | 10kg | 8x | 3 sets

The logic is:
Muscle group:: Exercise | Weight | Reps | Sets

Now the “weird” queries:

## Chest query
```dataview
TABLE
	map(Chest, (c) => split(c, "\|")[0]) AS Exercise,
	map(Chest, (c) => split(c, "\|")[1]) AS Weight,
	map(Chest, (c) => split(c, "\|")[2]) AS Reps,
	map(Chest, (c) => split(c, "\|")[3]) AS Sets
FROM "03. Daily Notes"
WHERE Chest
SORT file.link ASC
```
## Shoulder query
```dataview
TABLE
	map(Shoulder, (s) => split(s, "\|")[0]) AS Exercise,
	map(Shoulder, (s) => split(s, "\|")[1]) AS Weight,
	map(Shoulder, (s) => split(s, "\|")[2]) AS Reps,
	map(Shoulder, (s) => split(s, "\|")[3]) AS Sets
FROM "03. Daily Notes"
WHERE Shoulder
SORT file.link ASC
```

The result (considering My Note 1 = [[2022-02-01]] and My Note 2 = [[2022-02-09]]):

1 Like

You are a legend mate. Thank you so much, specially for your time to think about it and practically came up with the solution. Heartfelt thanks to you again.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.