Multi Dimension Index-Match - google-sheets

I'm stuck with this assignment where I need to use index-match formula to input values from another sheet.
Google Sheet: https://docs.google.com/spreadsheets/d/182b4foaNURrAysA9pQ2rtFinU0U1TnwBDNHEkInbjiQ/edit?usp=sharing
I need to get value from Sheet "Mon-Sun" to show in the sheet "Work hour" using formula. My friend said I should use index-match, but I cannot seem to be able to do it (Only know how to do basic index-match). Been thinking for hours now but cannot find the solution. Please help.

Perhaps the following, which is just an INDEX with two MATCH's (ID and day of the week), and a bit of logic to handle your setup with merged cells, as well as whether it's Day or Night.
=index('Mon-Sun'!$B$3:$O$6,match($A4,'Mon-Sun'!$A$3:$A$6,0),match(if(isblank(C$2),B$2,C$2),'Mon-Sun'!$B$1:$O$1,0)+if(C$3="Day",0,1))

delete everything in range C4:Z
paste this in C4 cell and drag to the right:
=ARRAYFORMULA(IFNA(VLOOKUP($A4:$A, {'Mon-Sun'!$A3:$A, INDIRECT("Mon-Sun!"&ADDRESS(3,
MATCH(IF(C2="", B2, C2), 'Mon-Sun'!1:1, 0)+IF(C2="", 1, 0), 4)&":"&ADDRESS(ROWS('Mon-Sun'!A:A),
MATCH(IF(C2="", B2, C2), 'Mon-Sun'!1:1, 0)+IF(C2="", 1, 0), 4))}, 2, 0)))

Related

Google Sheets - Index, Match formula from multiple columns

I got a problem with one fromula.
Two sheets:
1st Sheet
2nd Sheet
Look at formula on 2nd sheet B2
=IFERROR(INDEX(Importrange("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!A:A"),
MATCH($A2,Importrange("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!B:B"), 0)), "Not ordered")
It is matching my status from 1st spreadsheet but only from B column. My question is how to add C column as well (add another match criteria). I want to have B and C together. Is it possible?
Thanks!
I've tried something like this but it is not working :
=INDEX("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!A:A"), MATCH($A2,Importrange("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!B:B"),
MATCH($A2,Importrange("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!C:C"), 0))
=IFERROR(INDEX(Importrange("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!A:A"),MATCH($A2,Importrange("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!B:B"), 0)), IFERROR(INDEX(Importrange("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!A:A"), MATCH($A2,Importrange("1sj7FlrO5ZbHkIUwtpkJdU3tokEBwEXRvyIpi6eVHig4","Sheet1!C:C"), 0)), "Not ordered"))
Try this! I joined a second exact formula as yours in the second parameter of the first IFERROR
It'd probably be easier to just do a an OR statement. So something like this.
=If(Or(isnumber(firstcolumnLookupFormula),
isnumber(SecondColumnLookupFormula)),"Ordered","Not Ordered").
You could do as many as needed then.

Formula to get next instance of row that contains specific text that works in ARRAYFORMULA

I'm building out a time tracking form and sheet.
I have everything working and I am able to get the next instance of a row that contains that user's name to get the elapsed time they were in that status.
The formula I am currently using is this:
=ArrayFormula(iferror(INDEX($A2:$A,SMALL(IF(B2=$B3:$B,ROW($B$2:$B)),1)), NOW()))
However, this does not work in an ARRAYFORMULA.
I've tried:
=ARRAYFORMULA(VLOOKUP(B2:B, {INDIRECT("B"&ROW(A2:A)+1&":B"), INDIRECT("A"&ROW(A2:A)+1&":A")}, 2, FALSE))
Which doesn't work in array formula because of INDIRECT.
=ARRAYFORMULA(SORTN(FILTER(A3:A, B3:B=B2), 1))
Doesn't work in ARRAYFORMULA
=ARRAYFORMULA(QUERY(A3:C, "SELECT MIN(A) WHERE B = '"&$B2&"' label MIN(A) ''"))
Doesn't work in ARRAYFORMULA.
These formulas all work if I drag them down manually but I don't want to have to open this sheet every couple of hours to drag it down.
Please help!
Link to sheet where I've been messing with formulas:
https://docs.google.com/spreadsheets/d/1ZZOFTFlhmanQPNfRreT2bBinlkb00uaK-qypmEMD3ww/edit
count it:
=ARRAYFORMULA(IF(B2:B="",,IFNA(VLOOKUP(
B2:B&COUNTIFS(B2:B, B2:B, ROW(B2:B), "<="&ROW(B2:B)),
{B2:B&COUNTIFS(B2:B, B2:B, ROW(B2:B), "<="&ROW(B2:B))-1, A2:A}, 2, 0), NOW())))

How to change the value of a cell only when everyone has left the house?

I have a sheet consisting of entries that look like this, which I use to keep track of when the members of my family are at home:
DateTime
User
In/Out
5/29 13:00
Mike
In
5/29 13:05
Fred
Out
The rows are added via automation from everyone's phone using IFTTT. I have some flexibility in the format, but not a lot.
I would like to create a cell that changes ONLY when everyone is out of the house. Another IFTTT rule will watch that cell, and when it changes it will start the roomba. So the cell should NOT change if anyone returns home, it should only change if everyone has left.
One way I can think to do this is to set the watched cell to the last timestamp when everyone has left the house. That way, it will only update to a new value when everyone has once again left. Anytime there's a new row, if the status of everyone is Out, it will update the last timestamp.
I'm having a little trouble composing the formulas to keep track of when everyone is Out. This involves looking back through the most recent entries and finding the last time everyone who isn't the current user was out. I figure I can use a filter and a reverse sort and a lookup for every row in the table, but this seems a little complicated and inefficient.
Is there a better way to accomplish what I want?
you could track it like:
=SORTN(SORT(B2:C, ROW(B2:B), 0), 9^9, 2, 1, 1)
and then:
=SUMPRODUCT(INDEX(SORTN(SORT(FILTER({B2:C,
ROW(B2:B)}, B2:B<>""), 3, 0), 9^9, 2, 1, 1)="Out",, 2))=
COUNTUNIQUE(B2:B)
where:
TRUE = everybody out
FALSE = someone in
to get a time when house is empty:
=IF(SUMPRODUCT(INDEX(SORTN(SORT(FILTER({B2:C,
ROW(B2:B)}, B2:B<>""), 3, 0), 9^9, 2, 1, 1)="Out",, 2))=COUNTUNIQUE(B2:B),
INDEX(SORTN(SORT(A2:C, ROW(B2:B), 0), 9^9, 2, 2, 1), 1, 1), "someone home")
I think I got it, many thanks to player0.
The columns in yellow are written by the IFTTT automation. Columns D and E are set to the status of Mike and Carrie, as of that time. D3 is set to:
=INDEX(TRANSPOSE(SORTN(SORT(A$2:C3, ROW(B$2:B3), 0), 9^9, 2, 2, 1)),3)
and filled down for the rest of column D, which also populates E.
Once you have a row with a timestamp and everyone's status, it's a relatively simple thing to pick out the latest row where everyone is out. Cell G4 is set to:
=INDEX(SORT(FILTER(A2:E,D2:D="OUT",E2:E="OUT"),1,FALSE),1,1)
In this example, it shows that the last time everyone was out was on 6/5, which is correct. As more rows are added, the value does not change again until the next time everyone is out, which is important for the automation that watches that cell for changes to know when to start the vacuum.
I am definitely open to more elegant solutions that don't need to drag a formula down column D, but for now this one seems to do the job.

Google sheets, how to create a table of Vlookup and get the last occurrence for each customer

I have a database of customers, where his zone, seller and some other values can change, and I want to generate a table of the last occurrence of each one
Heres a demo sheet
using Vlookup doesn't get the last occurrence
My database is very big and I need something to not slow my sheet that much, because I was using a formula like this one for each cell
=ARRAYFORMULA(LOOKUP(2,1/(C2:C=A2),$D$2:$D))
but the sheet is very slow because of this
Any help on this please ?
use:
=ARRAY_CONSTRAIN(SORTN(SORT({C3:E, B3:B}, 4, 0), 9^9, 2, 1, 1), 9^9, 3)

Creating a Automate Formula Which Repeats the Values according to Criteria (Dynamic Formula)

I have been finding a way where i can make this thing automate/Dynamic.
Below Sheet have two columns where Col"B" has such values like
KPM11
KPM22
KPM33
KPM44
KPM55
KPM66
KPM77
KPM88
KPM99
KPM100
KPM110
I want to repeat these values until next is start as i have settled it manually in Col"A".
Looking for a way/formula which makes it automate so i can drag it till the range or could be array.
Any help will be highly appreciated.
I have tried to create a formula but its out of my experience.
https://docs.google.com/spreadsheets/d/1IsCl9fcBMcLYiGLCmnJrk5a06bRCDigm7w2gGjqkCrE/edit#gid=0
try:
=ARRAYFORMULA(IF(B2:B="",, VLOOKUP(ROW(A2:A),
IF(REGEXMATCH(B2:B, TEXTJOIN("|", 1, H:H)), {ROW(A2:A), B2:B}), 2, 1)))

Resources