how to ARRAY specific cells based on rules? - filter

is there a (maybe a one (?) formula)-way how to pick all green cells (but only those which has numbers and excluding 0) in a row and put/list them in an array to that coresponding row ??
example: in cell AO1 there will be formula that will list these results:
AO1 = 647
AP1 = 2806
AQ1 = 15490
AR1 = 32105
AS1 = 33808
something like array of constants but constant will be a cell reference... I can only think of a hard way to doing it like make a table/grid of all green cells and then array them, but not sure how could I exlude things from arraying (things like: skip empty cell and skip cell that is "<1" )
edit: in another words: cell AO1: =arrayformula({$p$1;$r$1;$t$1;$v$1;$x$1;$z$1;$ab$1;$ad$1;$af$1;$ah$1;$aj$1;$al$1};and dont array empty and "<1" cells)

If the row are fixed could simply use filter on all the rows
like this : (I used the range you give in your question)
=FILTER(
{$p$1;$r$1;$t$1;$v$1;$x$1;$z$1;$ab$1;$ad$1;$af$1;$ah$1;$aj$1;$al$1};
{$p$1;$r$1;$t$1;$v$1;$x$1;$z$1;$ab$1;$ad$1;$af$1;$ah$1;$aj$1;$al$1}>0)
And for the K and the unique you can add them like this:
=ARRAYFORMULA(UNIQUE(FILTER(
{$p$1;$r$1;$t$1;$v$1;$x$1;$z$1;$ab$1;$ad$1;$af$1;$ah$1;$aj$1;$al$1};
{$p$1;$r$1;$t$1;$v$1;$x$1;$z$1;$ab$1;$ad$1;$af$1;$ah$1;$aj$1;$al$1}>0))&" K")

Related

How do I do fill down with formula in reverse order in Google Sheet

When I fill down with formula starting with, say, =A9, it will auto fill with =A10, =A11, A=12, in incrementing order. But I want it to fill down in reverse order as =A8, =A7, =A6, how do I do that? In Excel, I can select 2 cells, =A10 and =A9, Excel will know to fill in reverse order.
You could use the SEQUENCE function within the formula
=SEQUENCE(7,1,11,-1)
or even as
=SEQUENCE(7,1,11,-1)
EDIT
If you need to reverse the order of already existing values in cells you can use:
=SORT(A1:A9,ROW(A1:A9),0)
or even the following to exclude empty rows
=SORT(A1:A9,ROW(A1:A9)*N(A1:A9<>""),0)
try like this:
=SORT(ROW(A:A), 1, 0)
or if you want from 10 to 5
=SORT(ROW(A5:A10), 1, 0)
or to flip the column values:
=SORT(A9:A15, ROW(A9:A15)*N(A9:A15<>""), 0)

google spreadsheets - filter a cell by it's address

I am using the filter function to find non blank values, the classic:
=FILTER(A2:A99, NOT(ISBLANK(B2:B99)))
To find all the column A headings that have a non-blank value in column B.
But I would also like to always include the last value regardless of it's ISBLANK, something like:
=FILTER(A2:A99, (CELL("address",A2:A99)="$A$99") OR NOT(ISBLANK(B2:B99)))
But this gives me an error, leading me to the strange question of how do I get this to work:
=FILTER(A2:A99, CELL("address",A2:A99)="$A$99")
Or something similar?
As CELL function does not play well in array formulas, you can get addresses as strings for cells like this:
=ARRAYFORMULA(ADDRESS(ROW(A2:A99), COLUMN(A2:A99)))
As for your original problem, you can just add the last cell as the last row:
={FILTER(A2:A98, NOT(ISBLANK(B2:B98))); A99}
Or a dynamic version:
=FILTER(A2:A99, (NOT(ISBLANK(B2:B99))) + (ROW(A2:A99) = (ROWS(A2:A99) + ROW(A2) - 1)))

Get Capped Maximum Value From List

I have a list of values that range anywhere from 500-1000. I have a second list of values that denote relevant breakpoints in the 500-1000 range (500, 520, 540, 600, etc). I need to return the highest value in the second list that is less than the value in a given number from the first list. I noticed the "N" functions let you set a conditional on them, so for example if I do:
List.Max(List.FirstN(SomeTable[Breakpoints], each _ < 530))
It correctly returns 520 to me. However if I put this inside an AddColumn function and change the 530 to a local field reference:
Table.AddColumn(MyTable, "MinValue", each List.Max(List.FirstN(SomeTable[Breakpoints], each _ < [SomeNumbers])))
Then I get a "We cannot apply field access to the type Number" error. Is what I'm trying to do possible and I'm just formatting it wrong? I always get confused with scope and references in PQ, so it may just be that.
After each, [SomeNumbers] by itself is short for _[SomeNumbers] (which is what you see when filtering a column). In the List.FirstN call, _ refers to a number in the list instead of a row in a table: the value of _ is tied to the closest each, where closeness is measured by the number of layers of nesting between _ and the appearance of each . Therefore, in your code [SomeNumbers] is trying to find the column SomeNumbers on a number, which doesn't exist.
There are a couple ways to fix this:
You can use a let...in statement to store the current value of the SomeNumbers column to use it for later, like so:
each
let
currentNumber = [SomeNumbers],
result = List.Max(List.FirstN(SomeTable[Breakpoints], each _ < currentNumber))
in
result
You can explicitly define a function with the (x) => ... syntax instead of using each twice, like so:
each List.Max(List.FirstN(SomeTable[Breakpoints], (point) => point < [SomeNumbers]))

How to filter one list of items from another list of items?

I have a huge list of items in Column A (1,000 items) and a smaller list of items in Column B (510 items).
I want to put a formula in Column C to show only the Column A items not in Column B.
How to achieve this through a formula, preferably a FILTER formula?
Select the list in column A
Right-Click and select Name a Range...
Enter "ColumnToSearch"
Click cell C1
Enter this formula: =MATCH(B1,ColumnToSearch,0)
Drag the formula down for all items in B
If the formula fails to find a match, it will be marked "#N/A", otherwise it will be a number.
If you'd like it to be TRUE for match and FALSE for no match, use this formula instead:
=ISNUMBER(MATCH(B1,ColumnToSearch,0))
If you'd like to return the unfound value and return empty string for found values
=IF(ISNUMBER(MATCH(B1,ColumnToSearch,0)),"",B1)
Alternative method is simply =
FILTER(A1:A,if(COUNTIF(B1:B,A1:A),0,1))
It's much more efficient.
It uses countif to get a 0 or a 1 as an array if the values in B are in A, then it reverses the 0 and 1 to get the values that are missing instead of only the values that are in there. It then filters based on that.
Columns look like this
A B
1 2
2 5
3
4
5
ARE formulae:
=FILTER(A1:A, MATCH(A1:A, B1:B, 0))
=FILTER(A1:A, COUNTIF(B1:B, A1:A))
ARE NOT formulae:
=FILTER(A1:A, ISNA(MATCH(A1:A, B1:B, 0)))
=FILTER(A1:A, NOT(COUNTIF(B1:B, A1:A)))
in your case:
=FILTER(A1:A; ISNA(MATCH(A:A; B:B; )))
if you face a mismatch of ranges see: https://stackoverflow.com/a/54795616/5632629

jqGrid permutation array

In jqGrid I am trying to use the permutation array for saving the reorder state of the columns.
For eg. Basic column state is perm = [0,1,2,3,4] column 3 is hidden and column 0 is the checkbox. Now I have a custom context menu which I use to finally give me a perm array of [0,1,3,2,4]
I have read in the documentation that the permutation array needs to start with 1, is this right?
When I try using "remapColumns" functions of the jqgrid and pass the perm array, it works fine. But if I try hiding and showing columns a couple of times, the column order is getting messed with.
Please help me understand what these indices for the permutation array stand for? Are they column indexes for visible columns? Should hidden columns be part of array? What happens in case of frozen columns? In some examples I have seen perm = [0:1, 1:3, 2:2, 3:1]
What is the correct way? I am using grid.jqGrid("remapColumns", perm, true);
Try to use also the last parameter of the function
grid.jqGrid("remapColumns", [0,1,3,2,4], true, false);
permutation, updateCells, keepHeader
wiki:methods

Resources