Filtering using OR ...

adambc

Active Member
Joined
Jan 13, 2020
Messages
412
Office Version
  1. 365
Platform
  1. Windows
I've got 2 queries that separate out the records from a source file that satisfy ,,,

Power Query:
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ((Record.Field(_, Table.ColumnNames(#"Changed Type"){6})) <> null) and ((Record.Field(_, Table.ColumnNames(#"Changed Type"){8})) <> null) and ((Record.Field(_, Table.ColumnNames(#"Changed Type"){9})) <> null))

... which works perfectly (all 3 conditions have to be satisfied) and ...

Power Query:
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ((Record.Field(_, Table.ColumnNames(#"Changed Type"){9})) = null) or ((Record.Field(_, Table.ColumnNames(#"Changed Type"){8})) = null) or ((Record.Field(_, Table.ColumnNames(#"Changed Type"){6})) = null))

... which is causing me a problem!

If a record satisfies ((Record.Field(_, Table.ColumnNames(#"Changed Type"){9}))<> null) AND/OR ((Record.Field(_, Table.ColumnNames(#"Changed Type"){8})) <> null) - but satisfies the final test ie ((Record.Field(_, Table.ColumnNames(#"Changed Type"){6})) = null)), it is not picked up (the previous = null tests have failed and therefore not passed the record for the next test) ...

I've tried building 3 separate queries and then appending them, but I then don't have a field that I can use to Remove Duplicates (none of the records have a unique key field) ...

Is there another way to write my OR statement that I can use?

Or is there a different approach I can use?

Thanks ...
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I've got 2 queries that separate out the records from a source file that satisfy ,,,

Power Query:
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ((Record.Field(_, Table.ColumnNames(#"Changed Type"){6})) <> null) and ((Record.Field(_, Table.ColumnNames(#"Changed Type"){8})) <> null) and ((Record.Field(_, Table.ColumnNames(#"Changed Type"){9})) <> null))

... which works perfectly (all 3 conditions have to be satisfied) and ...

Power Query:
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ((Record.Field(_, Table.ColumnNames(#"Changed Type"){9})) = null) or ((Record.Field(_, Table.ColumnNames(#"Changed Type"){8})) = null) or ((Record.Field(_, Table.ColumnNames(#"Changed Type"){6})) = null))

... which is causing me a problem!

If a record satisfies ((Record.Field(_, Table.ColumnNames(#"Changed Type"){9}))<> null) AND/OR ((Record.Field(_, Table.ColumnNames(#"Changed Type"){8})) <> null) - but satisfies the final test ie ((Record.Field(_, Table.ColumnNames(#"Changed Type"){6})) = null)), it is not picked up (the previous = null tests have failed and therefore not passed the record for the next test) ...

I've tried building 3 separate queries and then appending them, but I then don't have a field that I can use to Remove Duplicates (none of the records have a unique key field) ...

Is there another way to write my OR statement that I can use?

Or is there a different approach I can use?

Thanks ...
IGNORE - I've solved the problem with a helper column using my OR statement above ...
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top