What I’m trying to do
I have a weekly notes system with Periodic Notes. I have a section of the weekly note template that looks like this:
>[!multi-column|right]
>
>>[!alos]+ ### *Workout*
>> #### *[[Data/weekly/Flessioni/Flessioni{{title}}|Flessioni]]*
>> ```dataview
TASK
FROM "Data/weekly/Flessioni/Flessioni{{title}}"
>> ```
>> `$= const value = Math.round(((dv.page("Data/weekly/Flessioni/Flessioni{{title}}.md").file.tasks.where(t => t.completed).length) / (dv.page("Data/weekly/Flessioni/Flessioni{{title}}.md").file.tasks).length || 0) * 100); "<progress value='" + value + "' max='100'></progress>" + " " + value + "%"`
Where “!alos” is just a custom callout; “{{title}}” is in this format “gggg-[W]ww-MMM” (e.g., at current time is “2025-W04-Jan”); “Flessioni{{title}}” is a note I create weekly, that contains only tasks (at current time it’s “Flessioni2025-W04-Jan”) and it looks like this:
and the weekly note, with such code, looks like this:
What I’m trying to do, is to replicate this in my dashboard note, but the problem of course is that I can’t use the “{{title}}” part of my code, because the note has a different title, but also because I need that part to change dynamically week by week.
Things I have tried
So, I’ve looked around the internet and this forum for something that could help me, and I’ve tried with many different variations of code which I can’t exactly recall. I guess the problem is that I just don’t have the knowledge of the required syntax to write this, since even the working code in the weekly note, I just got it from the internet, I didn’t write it myself. Anyways, I’ve tried different variations of this:
>[!multi-column|right]
>
>>[!alos]+ ### *Workout*
>> #### *`=link("Data/weekly/Flessioni/Flessioni" + dateformat(date(today), "yyyy-'W'WW-MMM"), "Flessioni")`*
>> ```dataview
TASK
FROM "Data/weekly/Flessioni/Flessioni + dateformat(date(today), 'yyyy-'W'WW-MMM')"
>> ```
>> `$= const value = Math.round(((dv.page("Data/weekly/Flessioni/" + dv.span(dv.func.dateformat(dv.date('today'), "yyyy-'W'WW-MMM")) + ".md").file.tasks.where(t => t.completed).length) / (dv.page("Data/weekly/Flessioni/" + dv.span(dv.func.dateformat(dv.date('today'), "yyyy-'W'WW-MMM")) + ".md").file.tasks).length || 0) * 100); "<progress value='" + value + "' max='100'></progress>" + " " + value + "%"`
So there are basically two things not working:
- the top dataview query, because of course that’s not a proper way to query my note
- the inline code, which for this particular instance of the code I wrote, returns this error: TypeError: Cannot read properties of undefined (reading ‘file’)