Filter table with "were" clause

I’m trying to filter a table with dataview:

```dataview 
TABLE WITHOUT ID 
test_1,
test_2,
FROM #testTable
where test_1 = 100

The table metadata are:

tags:: #testTable
test_1:: "100"
test_2:: "3"

tags:: #testTable
test_1:: "99"
test_2:: "32"

tags:: #testTable
test_1:: "100"
test_2:: "8"

But Obsidian doesn’t show me a table with 2 columns.
What’s wrong? Thanks guys!

Have you tried removing the final comma?

So your code would be this instead:

TABLE WITHOUT ID 
test_1,
test_2
FROM #testTable
where test_1 = 100

Yes, sorry. Of cause there is no comma.
So this isn’t it…

Maybe do you know a completely other way to filter tables?

TABLE WITHOUT ID,
test_1,
test_2
FROM #testTable
WHERE test_1 = 100

Maybe try this? It shows a comma here after the TABLE section.

I also capitalised your WHERE just in case that was causing any issues.

The alternative is using DataviewJS, though I don’t think that’s necessary in this case.


Edit: Then again, I don’t see a comma after the “TABLE WITHOUT ID” section in the examples it gives, like here.

So maybe the capitalisation of WHERE was the thing that was important:

TABLE WITHOUT ID
test_1,
test_2
FROM #testTable
WHERE test_1 = 100

Nop, this doesn’t work fine.
But thanks Sir.

If i forget a comma Obsidian shows me “Error…”.
But in my case Obsidian renders the table, but without any columns…

your values seems to be strings, maybe try without the quotes to have integer so it can compare with integer in the query ? (or make both into string if that’s what you meant to do)

1 Like

I’m sorry men. Thats also not the solution…

dv.table(["Test 1", "Test 2"], dv.pages('#testTable').map(f => [f.test_1, f.test_2]));

You can use this DataviewJS code instead if the standard Dataview is causing you issues.

I’m still not certain why the original code doesn’t work though, maybe it’s a problem with the underscores?

Can you tell me how to filter (test_1 = 100)?

double equals doesn’t do the trick? test_1 == 100 (and also ensuring the frontmatter property doesn’t have double quote or you get a type mismatch)

Nop again…

Did anyone tried anything of the “solutions”. Maybe it’s something with my settings etc.

Hi @Prosolution - if you are using the same field like test_1 multiple times in the same file, the values will be added to it in a list. So it will never just equal one value. You can check if the list contains one value with WHERE contains(test_1, "100").
In general, the best way to troubleshoot issues with WHERE is to remove the WHERE and see how the field shows up in your table! Does its appearance in the table match how you planned to filter it?
In your case, I would expect to see lists in each cell for test_1 and test_2 for any file where you set them multiple times. Note that if you sometimes set them only once, then my contains suggestion will not work there but = "100" should. Mixed up data types are complicated!

Good luck!

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