Help with "Where" function in Dataview

Hello there,

As per title I need help with data. My YAML header is as follows:

Client:
-Client 1
-Client 2

I need to be shown a table containing both client 1 and client 2.
I have tried with:

dataview
TABLE Client
Where contains(Client, “Client 1”) AND !contains(Client, “Client 2”)

But it does not work: the system returns ``No results to show for table query’'.
What can I do? Thank you very much.

Explanation

In programming, ! often represents a “not” operator

  1. C, C++, C#, Java, and similar languages:
    ! is used as the NOT operator to reverse a Boolean value. For example:
bool isTrue = true;
bool isFalse = !isTrue; // isFalse is now false
  1. JavaScript:
    In JavaScript, ! is used for logical NOT
var isTrue = true;
var isFalse = !isTrue; // isFalse is now false
  1. DQL
    Most importantly, in DQL, ! is used for NOT
SELECT *
FROM employees
WHERE is_manager != true;

Of course, there are exceptions, such as
Bash and Mathmatical Context

if ! command_that_might_fail; then
    echo "Command failed"
fi

5! represents 5 factorial, which is equal to 5 x 4 x 3 x 2 x 1 = 120


Solution

All of this to say, since you want it to list both #Client/Client 1 and #Client/Client 2 you need to remove !containts and replace it with contains

```dataview
TABLE Client
WHERE contains(Client, "Client 1") AND contains(Client, "Client 2")
```
1 Like

Hello there :slight_smile: thanks for the relply!

I try to remove the “!” sign, but the result remain the same: “Dataview: No results to show for table query”

Your YAML’s invalid. You have it like this:

Client:
-Client 1
-Client 2

You need a space between your dash and your value, like this:

Client:
- Client 1
- Client 2

Then use @smiggles’ solution and it should work.

1 Like

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