Limit counted values

What I’m trying to do

Hello forum,

lets say, I have some books with different themes (subjects).
I want to count this books with the themes.
So, all occurrences of a value (theme) should be counted but i want to limit the counts of a dataview query (in this case values > 1)

Things I have tried

my code looks like this:

TABLE
length(rows.file.link) AS Num
WHERE type = "Book" 
FLATTEN theme AS T
GROUP BY T

this works fine so far, but when I insert the line:

 WHERE Num >1

after the GROUP BY command, there are no more entries in the output.

How do I have to set the “limiter” that limits the output counts to only values > 1 ?

greetings

Calculations done in the header definitions are not stored, so they’re not able to be used in other parts of the query, but if you move it into a FLATTEN statement they can be used. So try the following:

```dataview
TABLE Num
WHERE type = "Book"  
FLATTEN theme AS T
GROUP BY T
FLATTEN length(rows.file.link) AS Num
WHERE Num > 1
```

It could be you should consider moving other parts of you query around, but moving it into FLATTEN statement preserves the value for use in other parts.

1 Like

Thanks holroy,

well, that’s what i thought, but i didn’t know how to implement it (syntax) - how to use a value that has yet to be calculated.

learned something again.

1 Like

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