DataView Habit Tracker

Could you share the entire note that this works with? I’ve copy and pasted you r code here and tried all the ones above it. I get headers to render properly, but never any results from completed tasks showing up.

EDIT: It worked after installing the tasks plugin
EDIT 2: Or maybe it worked after changing to YYYYMMDD. One of those fixed it :sweat_smile:

For a minimalist solution that does not requre templater, I just discovered this solution and it works well so far:

examples:

## Habits

**Reading**:: [[example link]]
**Sleep**:: 7
**Exercise**:: 60
**Highlights**:: 3
**Mindfulness**:: 0

and some magic in dataview

TABLE WITHOUT ID
  file.link as Date,
  choice(exercise > 30, "✅", "❌") as Exercise,
  choice(sleep > 6, "✅", "❌") as Sleep,
  choice(highlights >= 3, "✅", "❌") as Highlights,
  choice(mindfulness > 10, "✅", "❌") as Mindfulness,
  reading as Reading
FROM "daily"
WHERE file.day <= date(now) AND file.day >= date(now) - dur(7days)
SORT file.day ASC

this results in a nicely formatted table. thanks, Andrew!

3 Likes

Are there any things that need to be changed to make it work with my own system, such as a folder name or # I use in my daily notes to make it work?

not that I am aware of. for it to work, you only need

  • the dataview community plugin
  • adapt dataview variables as needed (see quote)
  • adapt folder in dataview table as needed -e.g. FROM “daily” or FROM “mydailynotesfolder/2022” (wherever your daily notes live)

Thanks for the post! I’m new to coding, and I’ve run into a No results to show for table query.

What would be the likely Issue?

  • Does it search for # {{date:MMMM D, YYYY}} on daily pages? Because I don’t have this format
  • Does it matter where my daily files are located as well?

Thanks a bunch!

Yes, the bit after FROM is the name of the folder to look through. Hope others can help with your other question!

Hi @DevinBaillie, i was thinking about the same and wanted a nice overview of my habits in a weekly setup.

I do daily journaling as well as weekly. For my weekly note i created the following plugin: GitHub - Narsail/habit-tracker-obsidian: A Plugin to display a Habit Tracker.

It is based on the Heatmap Calender of @richardsl and is very basic. But maybe it does suit your needs.

Best
David

1 Like

It doesn’t search for any specific date heading. The only thing it looks for in the actual notes are tasks under a header named “Habits”.

The notes should be named using a “YYYY-MM-DD” naming scheme and placed in a folder named “Daily Notes” (although that can be easily changed in the code).

I made a GitHub repo for the dataviewjs snippet to make it easier to find/keep updated. It includes the fixes provided by @Jigar and @DevinBaillie and now also filters out tag text.

3 Likes

I’ve followed your Genshii’s instructions exactly and seem to be getting no results from the dataview js query. Did either of you encounter this problem?

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