How to pass addresses to Vlookup based on cell values (Google Sheets) - arrays

This has me stumped, so I'm hoping somebody who knows the proper functions can help me out.
I am trying to do a VLOOKUP, but I want to pass the Range in based on values in columns.
The Range is on a different sheet than where the formula is, and I want the range's start column to be determined by looking for the value that is at the top of the column the forumla exists in.
For example, in the attached image, the 'Dashboard' sheet has Column A as Sheet, and the top Row has Widgets and Sprockets in the top row.
I want the Formula to be a Lookup for the search key 'Total, and return the value in the cell next to it. I want the Range to start on the sheet specified in Column A, and the Column to be the one with the value that matches the one at the top of the column where the formula is.
So my formula will look like
=VLOOKUP("Total",<INSERT RANGE HERE>,2)
Help would be appreciated.
Link to the Google Sheet:
https://docs.google.com/spreadsheets/d/1H5At3gHeTQUm6PWqeA7MT5xcm5RJ38NK6LyhSWUeaZY/edit?usp=sharing
Thanks Stack Overflow Community

I believe this is what you're looking for.
On the Dashboard sheet enter these formulas:
C3:
=vlookup("Total", indirect($A3&"!C1:D"),2)
D3:
=vlookup("Total", indirect($A3&"!C1:F"),4)
You can then select C3:D3 and drag down to autofill. I tried using an arrayformula and it didn't work, but I might have been doing it wrong
Also make sure to change "Position1" and "Position2" to match the sheet names exactly.
Edit: I just saw your screenshot. These formulas can also be put into C2 and D2, I just put them next to the sheet names to keep track of what I had to do.
Edit in response to comment:
This was the closest I could get to what you're looking for.
C3:
=vlookup("Total", indirect($A3&"!C1:"&ADDRESS(ROW(INDIRECT($A3&"!$C50")),COLUMN()+1)),2)
D3:
=vlookup("Total", indirect($A3&"!E1:"&ADDRESS(ROW(INDIRECT($A3&"!$E50")),COLUMN()+1)),2)
Again, these columns can be dragged and autofilled down with no issues.
I have the following formula that can be pasted onto the dashboard C3 cell, and then copied across: =address(1,match(C$1,indirect($A3&"!1:1"),0),,,$A3) This will give me the address I want from the Sheet I am trying to reference, i.e. Position01!$C$1 Also, If I use the following formula, I get the value I want as a result: =offset(Position01!$C$1,7,1,1,1) However, If I try to combine the two, I get the error 'Argument must be a range'. =offset(address(1,match(C$1,indirect($A3&"!1:1"),0),,,$A3),7,1,1,1)
You need to add INDIRECT in front of the first formula when placing it inside of the OFFSET one so that it reads the result address as a range instead of a string:
=offset(INDIRECT(address(1,match(C$1,indirect($A3&"!1:1"),0),,,$A3)),7,1,1,1)

use:
=INDEX({VLOOKUP("Total", Position01!C:F, {2, 4}, 0);
VLOOKUP("Total", Position02!C:F, {2, 4}, 0)})
update:
if your project consists of 24 rows but unknown number of columns then you can use range:
Position01!C1:24 (instead of Position01!C:F)
then to return every column you can do:
COLUMN(Position01!C1:1)-1 (instead of {2, 4})
or if you want to return every 2nd column:
FILTER(COLUMN(Position01!C1:1)-2, MOD(COLUMN(Position01!C1:1), 2)=0)
(instead of {2, 4})

Related

How do I generate the location (row and column) of a specific value in Google Sheets?

I made a schedule in Google Sheets (days of the week as columns, time as rows, student names within the chart). I want to make an additional chart restating the data by student name that will update if I move the students in chart 1. I would love it to report day and time, but would settle for any sort of location information whatsoever.
I have tried combinations of VLOOKUP, QUERY, and Match. The problem is that it only works as long as the student stays in the same location. If I move it to a different cell I get an error as it only works for a single row or column.
The closest I have gotten is that I can make a hyperlink to the cell. When you hover over the link it gives the cell location, but I don't know if it is possible to make the cell location the name.
https://docs.google.com/spreadsheets/d/1I5ZMOa8dEcVhYmbT-LDaqX-I7s5L5cH1QR8xVH4dVGQ/edit#gid=1364833249
try:
=INDEX(IFNA(VLOOKUP(A2:A, SPLIT(FLATTEN(
Schedule!B2:F&"×"&Schedule!B1:F1&"×"&Schedule!A2:A), "×"), {2, 3}, 0)))
Use this formula
=ArrayFormula(
SORTN(SPLIT(FLATTEN(Schedule!B1:F1&"^_~"&Schedule!B2:F6&"^_~"&Schedule!A2:A6),"^_~"),
COUNTA( INDEX(SPLIT(FLATTEN(Schedule!B1:F1&"^_~"&Schedule!B2:F6&"^_~"&Schedule!A2:A6),"^_~"), ,3)),,3,1))

Excel formula to return a value if two values are true and one of two other things are true

I'm trying to write a formula in Excel where if value in B is “Eligible/Previously Eligible” and value in C is more than 365 days before today and value in D contains either 10 or 20, then return the value in A. I’ve been searching around and have written this:
=IFERROR(INDEX($A:$A,SMALL(IF((COUNTIFS($B:$B,"Eligible/Previously Eligible",$C:$C,"<"&TODAY()-365,$D:$D,{"*10*","*40*"})),ROW($A:$D)-MIN(ROW($A:$D))+1),ROW(A1)),COLUMN(A1)),"")
And have activated with the CTRL+Shift+Enter combo, but it just pulls in everything from A regardless of what is in B, C, or D:
#Solar Mike and #Scott Craner, thanks! This has gotten me closer but not quite there. I have a formula now that works to return the ID numbers that meet the criteria:
=IF(AND(B2="Eligible/Previously Eligible",D2<TODAY()-365,D2<>"",OR(SUM(COUNTIF(C2,{"*10*","*20*"})))),A2,"")
But I still can't get it to give me a list without white space. So, I can get what's in the "ID Numbers with Problems" column, but what do I need to write to get it to show the way I've done it manually in the "What I want" column?
image of what
Add a helper column:
=and(find("*elig",B2,1)>=1,now()-c2>=365,D2/10<=2)
Drag down to test each row. Then a results table based on those that give true.
Or use sumproduct() with column A to give the IDs.

ArrayFormula to automatically calculate one column

I want an array formula to use with Google Forms data to automatically calculate running metrics on my data.
In this case, in column Q, AE and AS I want it to auto-calculate whenever new responses come in.
I'm trying to use this formula below but isn't working for all column, just for the first line.
={arrayformula(if(len(AF3:AF);SUM(vlookup(AF3:AR3;$A$1100:$B$1101;2;0));))}
I want a sum of all words that contain "Verdadeiro" in a row.
What I'm doing wrong?
My Google Sheet:
https://docs.google.com/spreadsheets/d/1AVQ772IIXI-xZza0fecTTCe4S-Ku9rL1houTMnQZpbo/edit?usp=sharing
try in row 1:
={"Total AG";""; ARRAYFORMULA(IF(A3:A="";;
MMULT(N(REGEXMATCH(A3:AR&""; "Verdadeiro")); SEQUENCE(COLUMNS(A3:AR))^0)))}

How do you use ArrayFormula with arrays (after aggregation)?

In my example:
https://docs.google.com/spreadsheets/d/1QQNTw_r9-q-FqVNwUoYklup73niZCFyO0VDUYImP5fo/edit?usp=sharing
I'm using Google Forms as an eBay clone to sell rare items. Each bid is outputted from the form to the "Data" worksheet and then I have ArrayFormulas set up inside the "Processed" worksheet. The idea is that I want to process the bids so that we filter everything except the items with the highest bids. All data should be automatically updated, hence why I want to use ArrayFormulas.
My strategy is that in colum A, I first filter all unique items (=unique(filter(Data!A2:A,Data!A2:A<>""))) and end up with:
Jurassic Park 6-Pog Hologram Set
Princess the Bear TY Beanie Baby
Holographic 1st Ed Charizard
However, then in column B, we have to find the highest bid that corresponds to that unique item, e.g.:
=IF(ISBLANK(A2),,ArrayFormula(MAX(IF(Data!A2:A=A2,Data!B2:B))))
However, I don't want to have A2 be a single cell (A2) but an array (A2:A) so that it doesn't have to be manually copied down the rows. Similarly, I also want columns D and E to be automatic as well. Is there any way to achieve this?
Not sure if it would be considered easier than the previously posted answer, but in case this thread is found in the future, I think that this is a slightly simpler way to solve these kinds of problems:
Try this on a fresh tab in cell A1:
=FILTER(Data!A:D,COUNTIFS(Data!A:A,Data!A:A,Data!B:B,">"&Data!B:B)=0)
I did some research and found an answer very similar to what you were looking for. After rearranging the formula slightly to match your sheet, I was able to get this to work:
=ArrayFormula(vlookup(query({row(Data!A2:A),sort(Data!A2:C)},"select max(Col1) where Col2 <> '' group by Col2 label max(Col1)''",0),{row(Data!A2:A),sort(Data!A2:D)},{2,3,4,5},0))
This formula automatically populates product name, highest bid, username, and timestamp. I ran some tests, adding my own random names and values into the data sheet, and the formula worked great.
Reference: https://webapps.stackexchange.com/a/75637
use:
={A1:D1; SORTN(SORT(A2:D, 1, , 2, ), 9^9, 2, 1, )}
translated:
{A1:D1} - headers
SORT(A2:D, 1, , 2, ) - sort 1st column then 2nd column descending
9^9 - output all possible rows
2 - use 2nd mode of sortn which will group selected column
1 - selected column to be marged based on unique values

EXCEL: Create Array Formula out of INDEX/MATCH with multiple results

my aim is to convert a massive excel sheet with different projects, employees and hours worked per month into an overview per employee. It should be possible to display the projects the employee is involved in and how many hours he worked per project per month.
The original sheet looks something like this:
I managed to find the projects Person A worked in by filtering through the INDEX/MATCH function. I applied the formula to the whole row where the employees are listed and receive multiple results of projects. My question is how to transform the formula into something more effective to copy all of the matched results (projects) into a column (see 1).
This is what I have so far, if matches the employee name in a certain area; the output is the first match of the project he is involved in:
=INDEX(B2:J3;1;MATCH("Person A";Sheet1!B3:E3;0))
How can I copy this to the bottom cells to copy all of the matched results? Does it help to create an array formula with this?
You can use he following formula in cell B9:
=IFERROR(INDEX($2:$2,SMALL(IF($3:$3=$B$8,COLUMN($3:$3)-COLUMN(INDEX($3:$3,1,1))+1),ROWS(A$1:A1))),"")
It indexes row 2 and looks for the column number of the first match in row 3 that equals the value in B8 (=Person A). When dragging down it will look for the second match ROWS(A$1:A1) will become ROWS(A$1:A2) = 2.
For Person B you can use this formula in cell B14:
=IFERROR(INDEX($2:$2,SMALL(IF($3:$3=$B$13,COLUMN($3:$3)-COLUMN(INDEX($3:$3,1,1))+1),ROWS(A$1:A1))),"")
I hope this is what you where looking for.
PS
if you paste the following formula in cell C9 you will get the sum result for Person A on Project XY in month 10 2019:
=IF(OR($B9="",C$8=""),"",SUMPRODUCT(($B$2:$K$2=$B9)*($B$3:$K$3=$B$8)*($A$4:$A$6=C$8),B4:K6))
Note: That is provided that the value in cell C8 equals the value in cell A4.

Resources