Filtering using OR ...

adambc

Active Member
Joined
Jan 13, 2020
Messages
377
Office Version
  1. 2019
  2. 2016
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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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,215,463
Messages
6,124,962
Members
449,200
Latest member
indiansth

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