Can you reference a dv field in same query?

What I’m trying to do

Im trying do to something like in the following example:

TABLE 1 + 1 AS "addTo2", 
addTo2 + 1 AS "addTo3"
FROM ""

I want addTo3 to output 3

Things I have tried

addTo2 + 1 AS “addTo3”

this.addTo2 + 1

field.addTo2 + 1

map(addTo2, (x) => x + 1)

I’ve searched the documentation but I can’t find anything. Is this possible?

Try the following:

```dataview 
TABLE WITHOUT ID addTwo, addThree
FLATTEN 1 + 1 AS addTwo
FLATTEN addTwo + 1 as addThree
WHERE file.path = this.file.path 
```

That last line is just to limit the query to the current file (to avoid the calculation to be repeated for every file in your vault). You might want to tailor that in your real use case. If you want to use FROM inn combination with FLATTEN, the FROM clause needs to be in front of the FLATTEN.

1 Like

Is it possible to achieve this without having to flatten the table?

What do you mean? The flatten applies to every row of the table, so there is no problem doing similar stuff on each and every row.

In the example I limited it to just the current file, just to not repeat the same calculation over and over again for every file in the vault.

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