# M code for Select All



## Nothnless (Sep 28, 2020)

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.


----------



## GraH (Sep 28, 2020)

In that step, remove the filter.  You will have the code. 
= Table.SelectRows( #"Removed Columns", each true)


----------



## sandy666 (Sep 28, 2020)

Power Query documentation - Power Query
					

Power Query is used to filter, combine, and mash-up data from one or more supported data sources.



					docs.microsoft.com


----------



## Nothnless (Sep 28, 2020)

GraH said:


> 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.


----------



## smozgur (Sep 29, 2020)

Instead of switching code lines, you can use a boolean variable as a switch and use it as condition in the function:

```
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.


----------

