DataviewJS flooring array reduce sum

What I’m trying to do

I’m trying to sum all the field keys within a folder in an inline query, and then display floor(result -10 / 2

Things I have tried

I currently have this inline code:

$= dv.paragraph(dv.pages('"Characters/Hero"').Strength.array().reduce((acc, val) => acc + val, 0))

I can perform arithmetic within the last )

$= dv.paragraph(dv.pages('"Characters/Hero"').Strength.array().reduce((acc, val) => acc + val, 0) - 10 / 2)

but cant seem to floor the value, putting math.floor or floor in and around the arithmetic.

Thanks for your attention and time :slight_smile:

Solved it:

let val = dv.pages('"Characters/Hero"').Strength.array().reduce((acc, val) => acc + val, 0) dv.el("t", (val - 10) / 2|0)

It uses bitwise or to round it down

It seems to not work with inline because of the |

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