PQ Filtering Tables within a column of Tables

cr731

Well-known Member
Joined
Sep 17, 2010
Messages
611
I have a table with a column of text values and a column of tables,

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Value I Want to Exclude
[/TD]
[TD]Column of Tables
[/TD]
[/TR]
[TR]
[TD]one
[/TD]
[TD]Table
[/TD]
[/TR]
[TR]
[TD]two
[/TD]
[TD]Table
[/TD]
[/TR]
[TR]
[TD]three
[/TD]
[TD]Table
[/TD]
[/TR]
</tbody>[/TABLE]

For the "Column of Tables," those tables will contain a column with values corresponding to the "Value I want to exclude" column - and I want to filter those tables to remove the row that matches the Value I Want to Exclude. So for line one, the Table in Column of Tables may look like

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Value to Match
[/TD]
[TD]Col1
[/TD]
[TD]Col2
[/TD]
[TD]Col3
[/TD]
[/TR]
[TR]
[TD]five
[/TD]
[TD]xx
[/TD]
[TD]xx
[/TD]
[TD]xx
[/TD]
[/TR]
[TR]
[TD]one
[/TD]
[TD]xx
[/TD]
[TD]xx
[/TD]
[TD]xx
[/TD]
[/TR]
[TR]
[TD]seven
[/TD]
[TD]xx
[/TD]
[TD]xx
[/TD]
[TD]xx
[/TD]
[/TR]
</tbody>[/TABLE]

For this table, I'd like to SelectRows and remove "one" since it is the value matching on that row of overall table. I tried adding a custom column like this

Table.SelectRows([Column of Tables], each [Value to Match] <> [Value I Want to Exclude]

but I get an error because the [Value I Want to Exclude] column is not part of the [Column of Tables] table, and I can't figure out how to access fields from the overall table in the SelectRows formula.

The other idea I had was to use an anti join but I don't want it to be applied against the whole table, just on a row by row basis.
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You were quite close with adding the column. The entire line of your code probably looks like this:

Code:
StepName = Table.AddColumn(PreviousStep,"NewColumn", each Table.SelectRows([Column of Tables], each [Value to Match] <> [Value I Want to Exclude]))

You can change this to something like:

Code:
StepName = Table.AddColumn(PreviousStep,"NewColumn", ([B]MainTable) => [/B]Table.SelectRows([Column of Tables], each [Value to Match] <> [B]MainTable[/B][Value I Want to Exclude]))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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