Properties: Obsidian Query for checkbox values, numbers and empty (null, No value) values

I have this note with YAML and search with built in queries:

---
aliases:
  - AAA
  - BBB
tags:
  - ccc
  - ddd
filename: YAML properties tests
erstellt: Sonntag, 03. September 2023, 09:26:45 Uhr
geändert: Sonntag, 03. September 2023, 09:26:45 Uhr
Text: Obsidian is the best
Text_empty:
List:
  - a
  - b
  - c
  - d
  - e
List_empty: 
Number: 7
Number_empty: 
Checkbox_true: true
Checkbox_false: false
Checkbox_empty: 
Date: 2023-09-03T09:36
DateTime: 2023-09-03T09:36
---

## 1 Tests

- [ ] All with Text
 
Problem: Shows also text_empty. The minus sign - does not exclude something.

```query
[Text:]
```


- [x] All with Text Obsidian is the best

```query
[Text:Obsidian is t]
```

- [x] All with Text_empty
```query
[Text_empty:]
```

- [ ] All with List

Shows also List_empty

```query
[List:]
```


- [x] All with List, that contains c and e and a

No exclusion of a list-element possible

```query
[List: c] [List:e] [List:a]
```


- [x] All with List_empty

```query
[List_empty:]
```


- [ ] All with number

Shows also slideNumber, Number_empty, ...

```query
[number:]
```

- [ ] All with number 7

Does not work.

```query
[number: 7]
```


- [ ] All with date

Shows also updated, datetime, dataview, ...

```query
[date:]
```

- [ ] All with date 2023-09-03T09:36

Shows also dateTime.

```query
[date:2023-09-03T09:36]
```

- [x] All with datetime

```query
[dateTime:]
```

- [x] All with datetime 2023-09-03T09:36

```query
[dateTime:2023-09-03T09:36]
```

- [x] All with checkbox

```query
[checkbox:]
```

- [x] All with checkbox true

```query
[checkbox:true]
```

Does not find.

- [x] All with checkbox true

Does not find.

```query
[checkbox:false]
```

How is it possible to

  • exclude some property queries, for example with a minus (-) sign?
  • search for a note with has a number in a numeric field?
  • search for checkbox true/false
  • search for empty values?

Hi @merlinuwe ,
i’ve tried your query and it seems like you are not using correct YAML syntax.
If i modified all parameters based on this syntax searching starts working again.
Can you try close all your strings in parameters to “” and try it again?
I’ve tried these changes:

and query like

number 

produces this result:

or i was missunderstand and you want get value of that key (example: if you search term “Number” you want 7 as result) ?

Thank you very much.

Now I use this YAML:

---
aliases: [AAA, BBB]
tags: [YAML, properties, test]
filename: YAML properties tests
erstellt: Sonntag, 03. September 2023, 09:26:45 Uhr
geändert: Sonntag, 03. September 2023, 19:14:38 Uhr
Text: Obsidian is the best
Textempty: Uwe
List: [a, b, d, e]
Nummer: 7
Date: 2023-09-03T09:36
DateTime: 2023-09-03T09:36
Checkbox1:
Checkbox2: false
Checkbox3: true

---

As you see, I have no “” used as you suggested, but most of the queries now run.

To exclude some property queries, one can look at these examples:

- [x] OK AAA UND BBB NOT CCC 

```query OR
[aliases:AAA] [aliases:BBB] -[aliases:CCC]
```

Alternative

```query OR
[aliases:AAA] [aliases:BBB] -([aliases:CCC])
```

If I search for this, I’d like to see all notes which have a 7 in their field Nummer:

- [ ] Show all notes with field Nummer and value 7
==not working==

```query
[Nummer: 7]
```

But this does not work. What can I do?


Both of the following don’t work.
I’d like to see all notes, that have a false in their checkbox2 field.
I’d like to see all notes, that have a True in their checkbox3 field.
Wrong syntax?

## 2 Checkbox

- [ ] Alle Notizen mit checkbox2 false

==not working==

```query
[checkbox2: "false"]
```


- [ ] Alle Notizen mit checkbox3 true

==not working==

```query
[checkbox3: True]
```

For me, there is a lack of information how to do these queries. Perhaps someone can edit help.obsidian.md accordingly?

This is why iam using dataview plugin, its more powerfull than basic query.
I’ll try help you tomorrow again … good night :first_quarter_moon_with_face:

1 Like

Thank you very much.

I found four workarounds with dataview:

Dataview query of checkboxes

TABLE WITHOUT ID 
file.link
FROM ""
WHERE Checkbox3 = true
TABLE WITHOUT ID 
file.link
FROM ""
WHERE contains(Checkbox3, true)

Dataview query of fields with numbers

TABLE WITHOUT ID 
file.link
FROM ""
WHERE Nummer = 7
TABLE WITHOUT ID 
file.link
FROM ""
WHERE contains(Nummer, 7)

But I think, that should also be possible with such native Obsidians queries:

(Not working)

```query
[checkbox2: "false"]
```

```query
[checkbox3: True]
```

```query
[Nummer: 7]
```

Good night.

Good morning, Uwe! :wave:
I’ve tried using your YAML in my vault again, and because of yesterday’s Obsidian update (which introduced properties), there’s a YAML syntax error once more. This is what I believe is causing the issue with your query.
When I construct YAML properties with a datatype set, everything works correctly.
Example:
‘’‘query
[Nummer]
‘’’
Result
image

‘’‘query
[Nummer]: 7
‘’’
Result
image

‘’‘query
[Checkbox3]
‘’’
Result
image

‘’‘query
[Checkbox3]: true
‘’’
Result
image

But YAML propertiew have to been properly formated (now its easy with properties)
image

You can see datatype by icon next to the property.
Hope this helps :wink:

EDIT:
If I switch YAML to the old version, as you can see in this image, ‘Nummer’ is set to ‘Number’ datatype, but it is enclosed in double quotes (“”), unlike other strings in properties which don’t have double quotes at all. So, I believe the logic has been reversed now, where numbers are enclosed in double quotes, and text is not.
image

Thank you very much.

Unbelievable - exactly the other way around, as one should assume, is correct …

For others: In dataview, you have to use “7” as well as in YAML front matter.

```dataview
TABLE WITHOUT ID 
file.link
FROM ""
WHERE Nummer = "7"
```

Arbeitet erst nach dem Neustart von Obsidian:

```dataview
TABLE WITHOUT ID 
file.link
FROM ""
WHERE contains(Nummer, "7")
```

As a Python fan, who works with this syntax:

print(“Hello, this is number”, 42)

I would have continued to search unsuccessfully for years … thanks again!

BTW: The solution for the checkboxes is similar:

```query
[checkbox1:]
```

(Can also be: False)
```query
[checkbox2: false]
```

(Not consistent)
```query
[checkbox3: "True"]
```

In dataview, false and true must be written in lower case …

TABLE WITHOUT ID 
file.link
FROM ""
WHERE Checkbox2 = "false"
TABLE WITHOUT ID 
file.link
FROM ""
WHERE contains(Checkbox3, "true")

But … watch the attention signs:

Here is the last release of my note:


---
aliases: [AAA, BBB]
tags: [YAML, properties, test, dataview, query]
filename: YAML properties tests
erstellt: Sonntag, 03. September 2023, 09:26:45 Uhr
geändert: Montag, 04. September 2023, 20:07:28 Uhr
Checkbox1: ""
Checkbox2: "false"
Checkbox3: "true"
cssclasses: 
Date: 2023-09-03T09:36
DateTime: 2023-09-03T09:36
List: [a, b, d, e]
Nummer: "7"
Text: Obsidian is the best
Textempty: Uwe
---

## 1 Tests II

Auf die Achtung-Zeichen im YAML achten!

<https://forum.obsidian.md/t/properties-obsidian-query-for-checkbox-values-numbers-and-empty-null-no-value-values/66431>

- [x] OK AAA

```query
[aliases:AAA]
```

- [x] OK BBB

```query
[aliases:"BBB"]
```

- [x] OK AAA UND BBB

```query
[aliases:AAA] [aliases:BBB]
```

- [x] OK AAA UND BBB UND CCC

```query OR
[aliases:AAA][aliases:BBB] OR [aliases:CCC]
```

- [x] OK AAA OR BBB OR CCC

```query OR
[aliases:AAA] OR [aliases:BBB] OR [aliases:CCC]
```

- [x] OK AAA NOT CCC

```query OR
[aliases:AAA]  -([aliases:CCC])
```

- [x] OK AAA UND BBB NOT CCC

```query OR
[aliases:AAA] [aliases:BBB] -[aliases:CCC]
```

Alternative

```query OR
[aliases:AAA] [aliases:BBB] -([aliases:CCC])
```

- [x] OK AAA UND BBB UND CCC

```query OR
[aliases:AAA] [aliases:BBB] ([aliases:CCC])
```

---

Problem: Shows also text_empty. The minus sign - does not exclude something.

- [x] Die beiden Felder müssen existieren, egal ob und was drin steht.

```query
[Text:] [Textempty:]
```

- [x] Das Feld muss mit diese Text beginnend vorhanden sein.

```query
[Text:Obsidian is t]
```

- [x] Das Feld Textempty wird abgefragt, ob es existiert

```query
[Textempty:]
```

- [x] Das Feld Textempty wird abgefragt, ob Uwe drinsteht.

```query
[Textempty:Uwe]
```

- [x] Zeige alle Notizen, in denen NICHT im Feld Textempty das Wort Uwe steht. Das beinhaltet auch alle Notizen, die das Feld gar nicht haben.

```query
-[Textempty:Uwe]
```

- [ ] Zeigt alle Notizen, die über das Feld List verfügen, egal, was drinsteht.

```query
[List:]
```

- [x] Zeige alle Notizen, die zumindest a, b und d in der Liste enthalten.

```query
[List: a] [List:b] [List:d]
```

### 1.1 Zahlen

- [x] All with number

Shows also slideNumber, Number_empty, …

(Die Felder können klein und groß geschrieben werden, zumindest in einer Notiz-Query.)

```query
[Nummer:]
```

- [ ] Alle Notizen mit Nummer 7 anzeigen

Die Nummer muss (genau umgekehrt, wie in Python - aua!) *oben* in *Anführungszeichen* stehen und hier in der Abfrage *nicht*.

```query
[Nummer: 7]
```

dataview

```dataview
TABLE WITHOUT ID 
file.link
FROM ""
WHERE Nummer = "7"
```

Arbeitet erst nach dem Neustart von Obsidian:

```dataview
TABLE WITHOUT ID 
file.link
FROM ""
WHERE contains(Nummer, "7")
```

### 1.2 Datum

- [x] All with date

Shows also updated, datetime, dataview, …

%%

```query
[date:]
```

%%

- [x] Alle Notizen mit date 2023-09-03T09:36

Zeigt auch dateTime.

```query
[date:2023-09-03T09:36]
```

- [x] Alle Notizen mit dateTime

```query
[dateTime:]
```

- [x] Alle Notizen mit dateTime 2023-09-03T09:36

```query
[dateTime:2023-09-03T09:36]
```

## 2 Checkbox

- [x] Alle Notizen mit Checkbox1, unabhängig von derem Inhalt.

```query
[checkbox1:]
```

- [x] Alle Notizen mit checkbox2 false

```query
[checkbox2: false]
```

- [x] Alle Notizen mit checkbox3 true

Arbeitet auch nach dem Neustart von Obsidian nicht:

```query
[checkbox3: "True"]
```

Arbeitet manchmal erst nach dem Neustart von Obsidian:

```dataview
TABLE WITHOUT ID 
file.link
FROM ""
WHERE Checkbox2 = "false"
```

Arbeitet manchmal erst nach dem Neustart von Obsidian:

```dataview
TABLE WITHOUT ID 
file.link
FROM ""
WHERE contains(Checkbox3, "true")
```

Great, I’m glad you’ve finally figured it out! :+1:

1 Like

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