Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
adurham1920
Frequent Visitor

'Filtering Rows' step does not work for 'Not Equals' condition in conjunction with an OR operator

Hi All,

I've encountered an issue with the Power Query editor when trying to filter rows using the "OR" operation with the "Not Equals" Conditional logic. This is a fundamental boolean logic issue - so I'm concerned given that this seems to be replicable in Excel and Power BI Desktop.

 

Sample data/Power Query Script below:

 

 

 

ID	Name
110	A
112	B
113	A
114	C
118	C
200	C
204	A
290	E
492	D
921	B
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0UNJRclSK1QGxjYBsJyjbGEncBMh2hrIt4GwjAxO4GksjQ7heE0uQOS4QNZYg810x1BsZGEDMiQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [ID] <> 112 or [ID] <> 204)
in
    #"Filtered Rows"

 

 


I've attached the data where the issue is reproducable, and I'm not sure where I am going wrong. 

I separated 3 tables to distinguish where the issue seems to occur - and where it doesn't. I am able to filter these rows out by using AND or individually filtering each row.

 

The issue occurs when I want to filter multiple numbers based upon a predefined condition. In the example, I am trying to exclude the records where the ID column is not the numeric values (112 or 204).

 

Based on the documentation here: Operators  and Logical Functions Reference :The OR Function should exclude a ROW if any argument matches the condition that it is not equal to 112 or 204. This does not match the expected output, as my initial 11 rows should be filtered down to 8. 

 

Expected output on the filter:

 

 

ID	Name
110	A
113	A
114	C
118	C
200	C
290	E
492	D
921	B

 

 

 

1 ACCEPTED SOLUTION
mussaenda
Super User
Super User

Hi @adurham1920 

 

Usually, if you are using <> for filtering, you must use "and" 

 

Hope this helps

View solution in original post

4 REPLIES 4
mussaenda
Super User
Super User

Hi @adurham1920 

 

Usually, if you are using <> for filtering, you must use "and" 

 

Hope this helps

olgad
Super User
Super User

I will try to think it over, 
but in Power Query I just know that when you have all values ticked and you untick some then it is always AND , 
when you have all values unticked and you tick some it is always OR.
So basically if you wanna filter for several values it is OR, when you wanna filter out it is AND. 
I want this OR that, i dont want this AND that basically:)


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime
olgad
Super User
Super User

Hi there,
use and not or

olgad_0-1674601493224.png

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Hi Olgad, 

Thanks for your response!

 

I understand that there is a simple workaround for this issue by using the "AND" condition, or by individually filtering each row. My question is centered around understanding why this applied step doesn't work - because logically it should. An OR Boolean condition should return TRUE where: 1 of the matching conditions has been found. In this case both of the logical conditions are true, but the rows do not return filtered on matching conditions and it appears to be a bug. I've used this type of filter in the past and have not encountered an issue, so I'm wondering why it's changed now.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors