What a simple table that pulls information from YAML looks like:

Code to insert:

```dataviewjs
const pages = dv.pages('"2. Areas/Занятие спортом/Динамика веса"')
  .where(p => p.Вес && p.date)
  .sort(p => p.date);

let rows = [];
let prevWeight = null;
const goal = 80;

for (let p of pages) {
  const date = new Date(p.date).toLocaleDateString();
  const weight = p.Вес;
  let diffDisplay = "–";
  let toGoal = `${(goal - weight).toFixed(1)} kg`;

  if (prevWeight !== null) {
    const diff = weight - prevWeight;
    if (diff > 0) {
      diffDisplay = `🟢 +${diff.toFixed(1)}`; // gaining weight = good
    } else if (diff < 0) {
      diffDisplay = `🔴 ${diff.toFixed(1)}`;  // losing = bad
    } else {
      diffDisplay = "➖ 0";
    }
  }

  rows.push([date, weight, diffDisplay, toGoal]);
  prevWeight = weight;
}

dv.table(["📅 Date", "⚖️ Weight (kg)", "📈 Difference", "🎯 To goal (80 kg)"], rows);```

const pages = dv.pages(‘“2. Areas/Занятие спортом/Динамика веса”’) — replace with your own path where your notes with YAML are stored Move the last three apostrophe characters to a new line


🧠 An explanation for those who want to understand this code more deeply:

This code isn’t just a table. It’s a smart weight tracker right inside Obsidian. It shows:

  • the entry date;

  • the current weight;

  • the change in weight compared to the previous entry;

  • how much is left to the goal (e.g. 80 kg).

And all of it — automatically, without Excel or third-party apps.


How is dataviewjs different from regular dataview?

Regular dataviewdataviewjs
You write it like in Excel: just table, sort, filter.You use JavaScript — which means you can do more complex logic: comparisons, calculations, emotions.
Good for simple lists and tables.Good for advanced trackers, calculations, visualisations.
Can’t calculate the difference between values.Can compare, calculate the difference and even output emoji depending on the result.

A step-by-step explanation of the code

const pages = dv.pages('"2. Areas/Занятие спортом/Динамика веса"')
  .where(p => p.Вес && p.date)
  .sort(p => p.date);
  • We take all the notes from the “Weight dynamics” folder.

  • We filter: we only need the ones that have both weight and date.

  • We sort by date — so it’s in order.


let rows = [];
let prevWeight = null;
const goal = 80;
  • rows — the table rows will be gathered here.

  • prevWeight — we’ll remember the previous weight to compare with the current one.

  • goal — your goal (e.g. 80 kg). The code will show how much is left.


for (let p of pages) {
  const date = new Date(p.date).toLocaleDateString();
  const weight = p.Вес;
  • We get the date and weight from each note.

  • We make the date readable (e.g. “27.05.2025”).


let diffDisplay = "–";
let toGoal = `${(goal - weight).toFixed(1)} kg`;
  • diffDisplay — what happened to the weight since last time.

  • toGoal — how much is left to the goal in kilograms.


if (prevWeight !== null) {
  const diff = weight - prevWeight;
  if (diff > 0) {
    diffDisplay = `🟢 +${diff.toFixed(1)}`;
  } else if (diff < 0) {
    diffDisplay = `🔴 ${diff.toFixed(1)}`;
  } else {
    diffDisplay = "➖ 0";
  }
}
  • We compare the weight: did it go up, down or stay the same.

  • We add a colour and an emoji:

    • 🟢 gained weight — good!

    • 🔴 lost — maybe you need to eat 😅

    • ➖ stayed the same — stability!


rows.push([date, weight, diffDisplay, toGoal]);
prevWeight = weight;
  • We add everything to the table.

  • We remember the current weight to compare with the next one.


dv.table(["📅 Date", "⚖️ Weight (kg)", "📈 Difference", "🎯 To goal (80 kg)"], rows);
  • We output a nice table:

    • date,

    • weight,

    • change,

    • how much is left to the goal.


💥 The result

You get a table right in Obsidian that:

  • calculates progress;

  • shows where you’re losing or gaining;

  • motivates you to continue.

It’s the perfect tool for self-development and tracking progress. And you made it yourself — without Excel, without apps, just on the basis of Obsidian.