I am trying to set up a template that includes the use of data view functionality to perform basic calculations. The intent was to be able to store the variables in a table. Access that table to perform the calculations.

Things I have tried

Calculation Note

Input Values

val1

val2

10

5

20

8

15

3

Calculation

TABLE
FROM [[Input Values]]
compute answer:: number = val1 + val2

The parsing fails on line 3 “compute answer”

Could someone with more experience in this topic provide guidance?
Thank You
Best Regards
-Tim C.

I don’t think that’s possible with dataview, because dataview works on frontmatter/metadata & notes, not on table values or tables for that matter.

You may want to check out the Numerals or Solve plugins instead, which allow creating inline formulas (look at their published screenshots), but they don’t work with tables either afaik.

If, however, tables are desired, you may want to look at the Excel plugin, which allows creating Excel-like tables that can be embedded inside notes along with calculations (look at its published screenshots)

Still, that video makes use of frontmatter/metadata, and a heavy load of custom JavaScript code, and I’m still not sure that it’s even possible to do a simple use case like the one you require.

I think you’d be better off with the Excel plugin mentioned earlier, which is easier to use than writing a lot of boilerplate custom JS code, which is not even guaranteed to be possible.

But hey, if someone else has another idea or can think of an approach to tackle this, I’ll be all eyes & ears.

If you want to do simple calculations within the table in a given note you might also use the advanced tables plugin. Then you set up the formulas under the table, and hit the recalculate button every now and then when you change the input.