DVJS

These are the code blocks I used in the related video. You can copy them from here and adapt them as needed or just download the fully functional Lean Habits Vault.

Dont forget!

To put the code blocks between triple tickmarks (```).

Body Measures (table)

dataviewjs
// Fetch and filter pages
let pages = dv.pages('"06 BJ/10 Daily"')
    .where(p => p.Weight > 0);

// Create table data
let dvTable = pages.array().map(p => [
    p.file.link, 
    `<div style="text-align:right;">${p.Weight.toFixed(1)}</div>`, 
    `<div style="text-align:right;">${p.BMI.toFixed(1)}</div>`, 
    `<div style="text-align:right;">${p.Fat.toFixed(1)}</div>`
]);

// Calculate averages
let avgWeight = (dvTable.reduce((acc, row) => acc + parseFloat(row[1].match(/>([^<]+)</)[1]), 0) / dvTable.length).toFixed(1);
let avgBMI = (dvTable.reduce((acc, row) => acc + parseFloat(row[2].match(/>([^<]+)</)[1]), 0) / dvTable.length).toFixed(1);
let avgFat = (dvTable.reduce((acc, row) => acc + parseFloat(row[3].match(/>([^<]+)</)[1]), 0) / dvTable.length).toFixed(1);

// Display the table with an average row
dv.table(["Date", "Kg", "BMI", "Fat %"], 
    [...dvTable, [
        "*Average*", 
        `<div style="text-align:right;"><i>${avgWeight}</i></div>`, 
        `<div style="text-align:right;"><i>${avgBMI}</i></div>`, 
        `<div style="text-align:right;"><i>${avgFat}</i></div>`
    ]]
)