# Difference between OR/AND in Filter expressions

**URL:** <https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023>\
**Category:** Support\
**Created:** [July 27, 2022, 5:21am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023 "2022-07-27T05:21:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 5:21am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/1 "2022-07-27T05:21:09Z")

</div>

I want to hide all tracks that contain either _Noise_ OR _Big Synth_ in the genre tag (semicolon delimitered), however I'm finding that using AND is giving results instead of OR, which seems to make more sense because I don't just want genre tags that contain both. This is the expression:  
`(NOT genre HAS "noise") OR (NOT genre HAS "Big Synth")`

And the AND version:  
(NOT genre HAS "noise") AND (NOT genre HAS "Big Synth")

Total tracks, unfiltered: 577  
Using OR expression gives me 575  
When using AND expression: 413

I _guess_ the AND version is giving correct results yet I don't understand how. I have also read the Filter Syntax docs.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [July 27, 2022, 5:44am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/2 "2022-07-27T05:44:02Z")

</div>

> [@b1zguy](#):
>
> I want to hide all tracks that contain either _Noise_ OR "Big Synth" in the genre tag  
> ...  
> `(NOT genre HAS "noise") OR (NOT genre HAS "Big Synth")`

a question about logic.  
NOT genre HAS "noise" gives you all files without "noise" (which includes "Big Synth")  
NOT genre HAS "Big Synth" gives you all files without "Big Synth (which includes "noise")  
And as you link them with OR, you should get all files where either condition becomes true - you seem to have 2 files in which both genres appear.  
If you link the 2 conditions with AND then both conditions have to be true so as soon as you find either "noise" or "Big Synth" in genre then that file is not displayed.

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 5:53am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/3 "2022-07-27T05:53:13Z")

</div>

Isn't either condition what I want? One song could have "noise" and the next song has "Big Synth" - and I wish both of them to be filtered out (ie. hidden from view).

It still sounds like using AND means a song's genre tag most contain "noise" and "Big synth" ...

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 5:54am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/4 "2022-07-27T05:54:12Z")

</div>

Oh wait, is the AND combining the results of both sets??? So each parenthesis has it's own 'sub-result' and the AND is merging as one "list", per say?

EDIT: Still not understanding what the OR is doing.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [July 27, 2022, 5:59am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/5 "2022-07-27T05:59:11Z")

</div>

It's a problem of formal logic.  
And formal logic does not always follow every-day language conventions.

> [@b1zguy](#):
>
> combining the results of both sets

Yes. Both conditions have to be true to give the result that the whole expression is true.

"OR" also combines both expressions. Only that with "OR" either set has to be true to give an overall result of the whole expression to be true.

See e.g.

> **[Logic](https://en.wikipedia.org/wiki/Logic)**
>
> Logic is the study of correct reasoning. It includes both formal and informal logic. Formal logic is the science of deductively valid inferences or logical truths. It studies how conclusions follow from premises due to the structure of arguments alone, independent of their topic and content. Informal logic is associated with informal fallacies, critical thinking, and argumentation theory. It examines arguments expressed in natural language while formal logic uses formal language. When used as ...

And, in the documentation

> **[Filter and Search – Mp3tag Documentation](https://docs.mp3tag.de/filter/)**
>
> Documentation on Filter and Search and keywords to form complex filter expressions. Mp3tag is the universal Tag Editor.

you find:

> Combines the filter expressions `<expr1>` and `<expr2>` by logical _and_ or _or_. Parentheses can be used to group combined expressions.
> 
> Example: `artist IS Hidden Orchestra OR artist IS The Cinematic Orchestra` Lists all files where an `artist` field is either `Hidden Orchestra` or `The Cinematic Orchestra`.

In a way I am glad that set theory, much laughed upon way back when, finally pays off.

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [July 27, 2022, 6:26am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/6 "2022-07-27T06:26:42Z")

</div>

> [@b1zguy](#):
>
> Oh wait, is the AND combining the results of both sets??? So each parenthesis has it's own 'sub-result' and the AND is merging as one "list", per say?
> 
> EDIT: Still not understanding what the OR is doing.

Maybe [this explanation](https://isaaccomputerscience.org/concepts/prog_concepts_logical?examBoard=all&stage=all) can help you to understand the logic behind AND and OR.  
Just remember the 3 assumptions for the `user_name`, the `score` and `game_over` in this example:

 ![image](https://community.mp3tag.de/uploads/default/original/2X/f/f8b9c967ea37cbcdd5f9d18ff253e7d743ef9f9a.png)

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 11:47am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/7 "2022-07-27T11:47:49Z")

</div>

Reading the formal logic makes sense but not when applied to mp3tag. Here's what I've calculated in the hopes that I can be shown the obvious!

**Total = 577**  
(genre HAS "Noise") = 97  
(genre HAS "Big Synth") = 69  
= 166

(genre HAS "Noise") OR (genre HAS "Big Synth") = 164 (577 - 164 = 413)  
(genre HAS "Noise") AND (genre HAS "Big Synth") = 2 (577 - 2 = 575)

^^^ These seem to add-up.

Flipping the logic adds up too:  
(NOT genre HAS "Noise") = 480 (480 + 97 = 577)  
(NOT genre HAS "Big Synth") = 508 (508 + 69 = 577)

And the final piece:  
(NOT genre HAS "Noise") OR (NOT genre HAS "Big Synth") = 575 (577 - 575 = 2)  
(NOT genre HAS "Noise") AND (NOT genre HAS "Big Synth") = 413 (577 - 413 = 164

  

Random examples of track genres:

1. `Big Room; Mainstage; Instrumental; Noise`
2. `Big Synth; Instrumental`
3. `Bounce; Electro House`
4. `Noise; Instrumental`

^^^ So I only expect the third track to appear in the result of a `(NOT genre HAS "Noise") OR (NOT genre HAS "Big Synth") ` search.  
And only the fourth track to appear when searching `

  

Maybe I'm over thinking things so missing the obvious. I think I'm not getting how the two expressions in `(NOT genre HAS "Noise") OR (NOT genre HAS "Big Synth") ` are merging results. Trying to picture a venn diagram in my head.

I guess I could just blindly use the AND version (`(NOT genre HAS "Noise") AND (NOT genre HAS "Big Synth") `) yet I prefer to understand what's happening for accuracy and learning!

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 11:52am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/8 "2022-07-27T11:52:22Z")

</div>

I also intend to grow this expression with more genre omissions. Eg:

`(NOT genre HAS "Noise") OR (NOT genre HAS "Big Synth") OR (NOT genre HAS "Instrumental")`

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 11:57am UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/9 "2022-07-27T11:57:39Z")

</div>

> [@ohrenkino](#):
>
> you find:
> 
> > Combines the filter expressions `<expr1>` and `<expr2>` by logical _and_ or _or_. Parentheses can be used to group combined expressions.
> > 
> > Example: `artist IS Hidden Orchestra OR artist IS The Cinematic Orchestra` Lists all files where an `artist` field is either `Hidden Orchestra` or `The Cinematic Orchestra`.
> 
> In a way I am glad that set theory, much laughed upon way back when, finally pays off.

I believe this is what I have done?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [July 27, 2022, 12:03pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/10 "2022-07-27T12:03:25Z")

</div>

> [@b1zguy](#):
>
> 1. `Big Room; Mainstage; Instrumental; Noise`
> 2. `Big Synth; Instrumental`
> 3. `Bounce; Electro House`
> 4. `Noise; Instrumental`
> 
> ^^^ So I only expect the third track to appear in the result of a `(NOT genre HAS "Noise") OR (NOT genre HAS "Big Synth") ` search.

The following tracks should show because:  
1: yes, as it does not have "Big Synth"  
2: yes, because it does not have "noise"  
3: yes, because it does not have "Big Synth" and does not have "Noise"  
4: yes, because it does not have "Big Synth"  
Have you tried  
`NOT (%genre% HAS "Noise" OR %genre% HAS "Big Synth")`

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 12:10pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/11 "2022-07-27T12:10:19Z")

</div>

OK, so I think I'm understanding what mp3tag is doing regarding the above example. Each expression within the parentheses generates its own 'true' list, then they're combined as one big list at the end with the OR part?

> [@ohrenkino](#):
>
> Have you tried  
> `NOT (%genre% HAS "Noise" OR %genre% HAS "Big Synth")`

Looks like only the first genre is getting filtered. I suspected this too with the earlier example expressions.  
Getting same results with this: `NOT (%genre% HAS "Noise")`

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [July 27, 2022, 1:24pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/12 "2022-07-27T13:24:08Z")

</div>

> [@b1zguy](#):
>
> Looks like only the first genre is getting filtered

If the first expression already leads to the result true, then the whole expression is true as you combined it with "OR".

Believe me: MP3tag filters correctly.  
It would be up to you to create a suitable test environment to deepen your understanding.  
If Mp3tag does not show the results that you expected then check why your expectation and the result does not match.

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [July 27, 2022, 1:40pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/13 "2022-07-27T13:40:11Z")

</div>

> [@b1zguy](#):
>
> Looks like only the first genre is getting filtered. I suspected this too with the earlier example expressions.

I have used some pretty complex filters in the past to drill down a library of ~25k files to exactly what I was looking for. Standard logic always applies, although often it can seem counter to what we may say in conversation. The more complex the filter, the more accurate you need to be with the terminology. But I can definitely confirm through positive experience that mp3tag applies the filter syntax as it should for all of the operators.

A word of caution in some more complex cases - if any of the fields you are filtering have some of the protected use characters (like `$` or `%`) you have to enclose that operation in double quotation marks. Out of habit I do this most of the time, as there is always a possibility that these characters can exist.

There are tons of websites that have examples of logic. All the fun details specific to how mp3tag uses filters that @ohrenkino mentioned previously here applies in all cases.

> **[Filter and Search – Mp3tag Documentation](https://docs.mp3tag.de/filter/)**
>
> Documentation on Filter and Search and keywords to form complex filter expressions. Mp3tag is the universal Tag Editor.

---

<div class="post-metadata">

**Author:** ![phw](https://community.mp3tag.de/user_avatar/community.mp3tag.de/phw/32/11831_2.png) [@phw](https://community.mp3tag.de/u/phw)\
**Post date:** [July 27, 2022, 4:30pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/14 "2022-07-27T16:30:58Z")

</div>

As said above the behavior you see is expected and correct.

```
(NOT genre HAS "noise") OR (NOT genre HAS "Big Synth")

```

This finds all tracks that either miss the genre "noise" _OR_ "big synth", as long as one or both of these are missing it's matched. Only for the two tracks that have both genres both the left and right part of the condition is false, and false or false is false.

```
(NOT genre HAS "noise") AND (NOT genre HAS "Big Synth")

```

This matches all tracks that miss both the genre "noise" _AND_ "big synth". So this is what you want.

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 7:54pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/15 "2022-07-27T19:54:31Z")

</div>

> [@MotleyG](#):
>
> A word of caution in some more complex cases - if any of the fields you are filtering have some of the protected use characters (like `$` or `%`) you have to enclose that operation in double quotation marks.

You mean like quote genre (like "genre") if I'm looking for the word in the genre tag?  
And if searching for _fa$t_ then I need to quote like this `fa"$"t` or `"fa$t"`?

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 7:57pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/16 "2022-07-27T19:57:57Z")

</div>

> [@phw](#):
>
> As said above the behavior you see is expected and correct.
> 
> ```auto
> (NOT genre HAS "noise") OR (NOT genre HAS "Big Synth")
> 
> ```

I don't know if it is working as expected because it's still showing results with those genres.  
Eg:

 ![Screen Shot 2022-07-28 at 5.57.01 am](https://community.mp3tag.de/uploads/default/original/2X/9/99a6d524b1efd71fd9733afd9d8e4f04e5df3a19.jpeg)

I used `(NOT genre HAS "noise") OR (NOT genre HAS "Instrumental")` this time.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [July 27, 2022, 8:00pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/17 "2022-07-27T20:00:08Z")

</div>

Could you tell us which results you get if you evalute each of the conditions for each of the selected tracks? Is the result "true" or "false"?

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 8:00pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/18 "2022-07-27T20:00:53Z")

</div>

OK, I woke up in the night thinking I understand what's happening. The OR version stops evaluating the other expressions when the first one is true. Then the AND version means the track cannot have any of the genre tag (eg. noise, big synth, instrumental) but it doesn't mean it must not contain all three to evaluate as true.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [July 27, 2022, 8:05pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/19 "2022-07-27T20:05:51Z")

</div>

> [@b1zguy](#):
>
> The OR version stops evaluating the other expressions when the first one is true

That is false.  
Your problem is the "OR".  
Any assembly of conditions joined with OR gets as overall result "true" as soon as 1 of the conditions is "true".  
MP3tag does not "stop" evaluating - you only see the overall result..

---

<div class="post-metadata">

**Author:** ![b1zguy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@b1zguy](https://community.mp3tag.de/u/b1zguy)\
**Post date:** [July 27, 2022, 8:10pm UTC](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023/20 "2022-07-27T20:10:54Z")

</div>

Sure here are some screenshots:

Blank

 ![Screen Shot 2022-07-28 at 6.06.21 am](https://community.mp3tag.de/uploads/default/original/2X/d/d4f0ec7e9ad04793b15d492cb5f4fd68e93a49f8.png)

  
`(NOT genre HAS "noise") OR (NOT genre HAS "Instrumental")`

 ![Screen Shot 2022-07-28 at 6.07.19 am](https://community.mp3tag.de/uploads/default/original/2X/b/ba623a934c40efd1a65ad642e6c7ed805e12097e.png)

  
`(NOT genre HAS "noise") AND (NOT genre HAS "Instrumental")`

 ![Screen Shot 2022-07-28 at 6.08.11 am](https://community.mp3tag.de/uploads/default/original/2X/e/e6ca98a7608f255a0963590f261a1b10b0778feb.png)

  
Hope these help.

[Next page](https://community.mp3tag.de/t/difference-between-or-and-in-filter-expressions/58023.md?page=2)
