Arrayformula - Autofill Duplicate in each row - google-sheets

I have Table with conditional dropdown menus. Example:
Column A
Column B
Column C
Column D
Column E
Column F
Column G
Column H
Car
Gasoline
Tires
License
Gasoline
OK
Boy
Danny
Adam
Andrew
Danny
OK
Boy
Adam
Adam
Andrew
Danny
OK
Car
Adam
Tires
License
Gasoline
FALSE
Car
Gasoline
Tires
License
Gasoline
OK
Column A - Main Dropdown
Column B - conditional-depends on Main (A)
Columns D,E,F - Options for conditional dropdown (depends on Main (A)
Column H - Verificator - This is what I need.
I am looking for ARRAYFORMULA that will Find out if Column B is OK (choosen from D,E or F) - for each row, and if not- then gets some kind of message- like "FALSE".
so for each row separately - and it has to be arrayformula because rows are added via script and I don't want to copy formula to each row every time. and it has to check row by row so B1 - D1:F1, B2- D2:F2 .. in reality I have this options from "R" to "HI" so if possible please do not compare value with D / E / F separately.
Also if there is some kind of workaround to not to have columns for conditional dropdown, it would be perfect.

You may try something like this. It will try to match value in R to HI from that row (that's why I used INDEX, to narrow the search):
=BYROW(B:B,LAMBDA(each,IF(each="","",IFERROR(XMATCH(each,INDEX(R:HI,ROW(each))),FALSE))))
It will return the number of column or FALSE if it isn't found, you may add ">1" to return TRUE if found:
=BYROW(B:B,LAMBDA(each,IF(each="","",IFERROR(XMATCH(each,INDEX(R:HI,ROW(each)))>1,FALSE))))

Related

Add\remove row based on value

I got a table_1 that has 2 columns in (Q and R) the end with checkboxes.
I want to create and secondary table_2 that has dependency on the table_1 in such a way that it imports rows from Table_1 when I have TRUE value in column Q but removes it when I set value to TRUE in column R.
I tried using Filter, but it does not work after I alter data in table_1.
Basically, I want to make it work all the time. Not just once.
https://docs.google.com/spreadsheets/d/1I9RwXYBeibhL-mQBsSZHbB5QEBD24gbUBWldBucNmsw/edit?usp=sharing
You should use FILTER formula or QUERY formula.
Let's say you want to have a Sheet2 based on Sheet1 where you show only orders paid (P) but not delivered (Q) yet:
Source sheet according to your link:
Solution:
=FILTER(Sheet1!B2:R;Sheet1!P2:P=TRUE;Sheet1!Q2:Q=False)
First parameter: Sheet1!B2:R tells what will be displayed (all rows from 2 to the end and columns from B to R)
Second and Third parameters set conditions that are checked for each row separately.
If you want to have tick boxes in Sheet2, you should select P and Q columns and use Menu --> Insert --> Tick box.
It will change format of these columns but will not affect the content.

Google Sheets - get value from above

I'm trying to work out a function in a Google Sheets cells to look at a column then search current row and "above" the current row to find a non number value (text).
I have data that in two columns B (item code or category) & C (item description).
I need another column to contain the categories for each item - column D. I'm looking for a formula for this column, ideally an Arrayformula as the data can change, there can be multiple items per category, some might be only 1 item, some might be 100 items per category. The arrayformula in column D will get the category from column B if it is not a number.
B column - categories and item codes, C column - item descriptions, target is D column a copy of the categories from column B.
I've tried this numerous times and usually give up, do it manually but it becomes teadious quickly. Looking forward to any help that might come from this! thanks.
In D2 try
=Arrayformula(if(isnumber(B2:B), vlookup(row(B2:B), filter({row(B2:B) , B2:B}, istext(B2:B)), 2), B2:B))
and see if that works?
Try in D1
={"Category";ArrayFormula(lookup(row(B2:B),row(B2:B)/if(isnumber(B2:B),0,1),B2:B))}

Calculations Dependent On Multiple Drop-down Selections

I have the following spreadsheet calculating my household outgoings with a number of categories to choose from multiple drop-down lists (Cols B, C).
In Column H, with the header Outgoings, I would like to sum the columns D and E in two rows based on the selections made in the drop-down lists in J2, J3 which act as filters for said calculation. These drop-down lists reflect the Bill Type in Column B, and the Category in Column C.
As an example, if I selected from the drop-downs in Column J: Personal, Credit/Debit then I would like the two rows in Column H (Outgoings) to be populated with the total sum of the rows D and E, respectively, for where the Bill Type and Category in B and C match Personal and Credit/Debit.
Along with the above conditions, if there is no selection in either of the Column J drop-downs, I would like the rows in Column H (Outgoings) to simply provide the calculation of the incomes in D, E (Row 2) minus the remaining sum of each column (total outgoings, i.e. D2:D).
I'm a little new with the syntax required to perform more complex calculations and was wondering if this was achievable in spreadsheets, specifically, in Google Sheets.
Try this in cell H2:
=if(J2&J3="",
sum(filter(D:D,C:C="Income"))-sum(filter(D:D,C:C<>"Income")),
sum(filter(D:D,B:B=J2))+sum(filter(D:D,C:C=J3))
)
This in H3:
=if(J2&J3="",
sum(filter(E:E,C:C="Income"))-sum(filter(E:E,C:C<>"Income")),
sum(filter(E:E,B:B=J2))+sum(filter(E:E,C:C=J3))
)

Googlesheet merge 2 cells in next column based on their content

I have a Googlesheet with Column A= ID like B-124992 or D-133739 and several different ID's as well, Column B= Title description. I want to Merge only the "B-" and "D-" -like ID's with their respective Title description. I'm using ArrayFormula in column C like:
= ArrayFormula(IF(ISNUMBER(FIND({"B-","D-"};'BacklogData'!A2));A2&" - "&B2;""))
The result is merging as expected but the output is distributed in column C (shows all "B-" merge results) and column D ((shows all "D-" merge results).
How can I get the results all in column C?
In C2 try:
=ArrayFormula(if(len(B2:B); if(regexmatch(A2:A; "(B-|D-)"); A2:A&"-"&B2:B;);))
This will reference the colA and output the concatenation of col A and colB if col A starts with either B- or D.
NOTE: you will have to erase all formulas you currently have in col C.
Hope that helps ?
EDIT: not sure if you are referencing another sheet, but in that case you will have to add in the sheet name, like you did in the example you gave.
I don't think you need an array formula for this - all you need is an OR condition in a standard formula:
=IF(OR(LEFT(A2,2)="B-",LEFT(A2,2)="D-"),A2&" - "&B2,"")
and copy as far down column C as you need. Since this is not an array, it will only return one result per cell which is what you want.

Lookup value based on latest matching criteria

Below is an example of a table I have, what I am trying to do is get the value in the value column for a specific criteria based on the last occurrence (not including today's date).
So in the example below I want to find the value for the last occurrence of 'A', which is 12.
I think this can be done using an Index-Match, I just can't get my head around it though.
For example
Todays Date: 15/12/2013
---------------------------------|
|Date | Criteria | Value
|--------------------------------|
|12/11/2013 | A | 3 |
|16/11/2013 | B | 6 |
|27/11/2013 | C | 7 |
|3/12/2013 | A | 12 |
|5/12/2013 | B | 8 |
|15/12/2013 | A | |
----------------------------------
EDIT:
I would also like to add that this formula will be in a different sheet to the table above. The sheet reference in the formula also needs to be dynamic, it will draw the sheet name from another cell.
I would use this formula:
=index(C:C,max(arrayformula(match(filter(A:A,B:B="A",C:C<>""),A:A,0))),1)
This formula assumes that your data is in the columns A,B,C and for every "A" value in the Criteria column, the Date is different. (If that's not the case, then this formula won't work, see below.
Let's look the formula inside from outside:
filter(A:A,B:B="A",C:C<>"") - This will result with the dates where there is an "A" in the Criteria column, and where the Value column is not empty.
arrayformula(match(filter(A:A,B:B="A",C:C<>""),A:A,0)) - In this step we basically find the row number in which those dates are present. The match function will search for the dates (counted in step 1). The arrayformula is needed because there will be more results.
max(arrayformula(match(filter(A:A,B:B="A",C:C<>""),A:A,0))) - This will find the maximum row number (The maximum row number which contains an "A" in the Criteria column)
index(C:C,max(arrayformula(match(filter(A:A,B:B="A",C:C<>""),A:A,0))),1) - Finally, we use the INDEX function to navigate to the value, which has the maximum row number.
Now, if you want this formula to work on another sheet, you should write, instead of for example:
=index(C:C,... => =index(Data!C:C,...
Assuming that your data is in your Data worksheet.
If you want to this sheet to be dynamic, it's a bit tricky. Let's assume, that you're getting the value of the sheet name from the G1 cell. Then you should write:
=index(indirect(concatenate(G1,"!C:C")),...
This is not so pretty as you should do this for every occasion when it occurs in that long formula (described earlier). Instead you can do some pre-work.
Let's write this to your H1 cell: =concatenate(G1,"!C:C") - If in the G1 cell the sheet name is "Data", then the H1 cell should contain: Data!C:C, similarly you can add to the
H2 cell: =concatenate(G1,"!A:A"),
H3 cell: =concatenate(G1,"!B:B")
Now you can write (and that's the final answer for your question I think):
=index(indirect(H1),max(arrayformula(match(filter(indirect(H2),indirect(H3)="A",indirect(H1)<>""),indirect(H2),0))),1) - where H1,H2,H3 will reference to your Data sheet's columns.
I hope it helps.
Use the following formula to accomplish that.
Formula
=QUERY(
B1:D6, // data
"SELECT D // select
WHERE // where clause
C = 'A' AND // first criterium
D IS NOT NULL // second criterium
ORDER BY B DESC // order by
LIMIT 1, // limit
0" // headers
)
for copy/paste
=QUERY(B1:D6, "SELECT D WHERE C = 'A' AND D IS NOT NULL ORDER BY B DESC LIMIT 1", 0)
Explained
The clue to the formula is the usage of the ORDER BY and the LIMIT options within the QUERY formula. The WHERE clauses will prepare the result in the first place. Next, column B (the dates) is ordered descendingly (highest first). The LIMIT option sets the amount of rows to be displayed at 1.
Example
I've created an example file for you: Lookup value based on latest matching Criteria
I appreciate this is a slightly old question, but there is a way that I achieved the goal of filtering an array which I found both more conceptually straightforward, and also more generally applicable than the other answers I have seen, using vlookup's definitional ability to pick the first matching value in an array.
PROBLEM, RESTATED:
Assuming sample data:
A...B...C...D...E, created by a google form
A is the form entry date
B, C and D are entries from a list (let's assume they are e.g. product name, geography, and sales date)
E is the value
If a new value is entered for a particular product, in a geography, on a date, then I want this to be used in preference to the older version of that same data.
SOLUTION:
If, in your form, you create three new columns:
F Unique test
G Test cells combined
H Unique cells
Then in column G, you create a combination of all the cells you want to test on (in this case B, C and E)
cell G2: "=arrayformula(B2:B & char(9) & C2:C & char(9) & D2:D)"
The next column is a restatement of the cells you want to filter based on (in this case the date in A)
cell H2: "=arrayformula(A2:A)"
And then finally in column F we actually undertake the test:
cell F2: "=arrayformula(A2:A=vlookup(G2:G,sort({G2:H},2,false),2,false))"
Breaking that down, the vlookup (vlookup(G2:G,[RANGE],2,false) compares the data in G2, G3...Gn with a [RANGE], which is a virtual array consisting of two columns, G and H, pre-sorted according to cell H in descending order.
i.e. For any unique value of G (the combination of test data) the vlookup will return the largest value of H
The last part is a simple comparison to the original data (A2, A3... An) to return TRUE or FALSE based on whether it is the latest version of the unique value.
A final step if needed would be to create a new sheet with "=filter('Form Responses 1'!A:E,'Form Responses 1'F:F=TRUE) to recreate the data without the older versions.
Hope this helps.

Resources