M code for Select All

Nothnless

Board Regular
Joined
Apr 28, 2016
Messages
142
Hi, I'm not understanding how this line knows what column I want to (Select All) on. I'm assuming it's knows because its the column I clicked on however, other functions don't do it this way.

#"Filtered Rows" = Table.SelectRows(#"Removed Columns", each true),

So lets say I have an [Index] column with row data 1-10. If I do a filter to show just 1,5,10 the M code looks like this:

#"Filtered Rows" = Table.SelectRows(#"Removed Columns", each [Index] = 1 or [Index] = 5 or [Index] = 10),

I can easily manipulate the second line of code to point to whatever column I want simply by changing [Index].
But for the first line of code how do I tell it what column I want to Select All? It doesn't give a column name in the formula and I haven't seen any other code that does it this way.

The reason I'm needing to do this is based on certain parameters selected in a worksheet that applies a filter, but I may need it to unfilter as well.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
In that step, remove the filter. You will have the code.
= Table.SelectRows( #"Removed Columns", each true)
 
Upvote 0
In that step, remove the filter. You will have the code.
= Table.SelectRows( #"Removed Columns", each true)

Okay so I guess it just knows which column I'm referring to because of the step that its in?
But if I actually do something to the column then it will refer to it?

Because if I apply the 1,5,10 filer to the index I get:
= Table.SelectRows(#"Removed Columns", each [Index] = 1 or [Index] = 5 or [Index] = 10),

But I'm wondering why it doesn't have a select all filter that looks something like this:
= Table.SelectRows(#"Removed Columns", each [Index] =true),

Thanks for the help anyway, I will employ some code to just change the step back to "= Table.SelectRows( #"Removed Columns", each true)" when applicable.
 
Upvote 0
Instead of switching code lines, you can use a boolean variable as a switch and use it as condition in the function:
Power Query:
SelectAll = true,
Result = Table.SelectRows(ChangedType, if SelectAll then each true else each ([index] = 1 or [index] = 5 or [index] = 10))

You can even get SelectAll value from a named range in the worksheet. So you wouldn't even need to edit code.
 
Upvote 0

Forum statistics

Threads
1,223,766
Messages
6,174,372
Members
452,560
Latest member
Turbos

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