How would I conditionally format a cell based on conditions being true in the sheet? - google-sheets

I choose to edit the problem instead of having it spread out in the comments section.
"List of Invaders" - The names here, I want to be automatically crossed out when certain conditions are met. These conditions are: When all of the corresponding "invader" names are marked as "complete" with a "1" instead of the "0" in the corresponding "Completed" and "Crafted" columns. The light blue columns are where the names are "hidden" for the formulas to get info from.
So far, the marked answer was working for the initial intention, the problem arose when I wanted to add more columns for the array and or formula to look at.
I added a text box to the spreadsheet to explain what it is that should happen.
Link to the spreadsheet: https://docs.google.com/spreadsheets/d/1P1Nbt8Ct8pem0AqHwjvroX96hHDkrXwqPUZqngGEdFE/edit?usp=sharing
You are free to edit this one for testing. It is just a copy.
Thanks for all the help so far! And I apologize if I am causing confusion as to what I want, I hope this new example helps clear it up.

=ARRAYFORMULA(IFERROR(REGEXEXTRACT(G3:3, JOIN("|", QUERY(VLOOKUP(
QUERY($E4:F, "select E where E is not null order by F"),
QUERY($E4:F, "where E is not null order by F"), {1,2}, 0), "select Col1 where Col2=1")))))
=ARRAYFORMULA(IFERROR(REGEXEXTRACT(G3:3, JOIN("|", QUERY($E4:F, "select E where F=1")))))

Another way to do this without an array formula would be
=AND(COUNTIF($E:$E,"="&G3)=SUMIF($E:$E,"="&G3,$F:$F),SUMIF($E:$E,"="&G$3,$F:$F)>0)
and apply it to the range G3:V3 which is all of your invaders listed.

Related

Match table with database based on input and return multiple rows - index Match / vlookup?

I'll try to explain this the best i can.
I've got a database that hardly ever changes on 1 tab and i've got a dynamic table on other tab which is generated with data from the web.
I am trying to set up a formula that changes the outcome based on the colors i selected.
i can't link the original sheet but i tried to put together a small test sheet to make it more clear
https://docs.google.com/spreadsheets/d/114DxB1vqdH9MHuE5jr-iR1WfUdjMk4sY0dtvkCN80Y8/edit?usp=sharing
The linked sheet discribes what i want to get.
i tried allot of formulas and the closest i got gave me only the first result and it was combination of filter and vlookup but i accidently deleted that and can't really reproduce it...
added formula to your sheet. Please test it out:
=ARRAYFORMULA(QUERY(LAMBDA(ax,{PROPER(INDEX(ax,,1)),IFERROR(SPLIT(VLOOKUP(INDEX(ax,,2),A:A&"🐠"&B:B,1,),"🐠"))})(QUERY(SPLIT(FLATTEN(D3:D&"|"&E3:E&"🐠"&TRANSPOSE(G3:G10)),"|",0,0),"Select * Where Col1!=''")),"Select * Where Col2!=''"))
-
Another option it stacks up different queries with REDUCE, also gives you a message if product is not found in that colour:
=REDUCE({A2:B2,"colour"},SEQUENCE(COUNTA(E3:E)),LAMBDA(a,v,{a; IFERROR (QUERY(A3:B100,"SELECT '"&INDEX(D3:D,v)&"',A,B where A = '"&INDEX(E3:E,v)&"' and B matches '"&JOIN("|",FILTER(G3:G,G3:G<>""))&"' label '"&INDEX(D3:D,v)&"' ''",),{INDEX(D3:D,v),INDEX(E3:E,v),"not found in any colour"})}))
try:
=INDEX(QUERY({VLOOKUP(A3:A10, {E3:E10, D3:D10}, 2, ), A3:B10},
"where Col3 matches '"&TEXTJOIN("|", 1, G3:G10)&"'", ))

Only apply complex arrayformula() to rows with certain value in dataset

I have a quite complext formula (i mean that is complex to me) that Tom Sharpe helped me building to aggregate values and ordering them by months in a row(you can find the details in the original post but i think you'll only need the final formula which is:
=ArrayFormula(mmult(sequence(1,counta(A2:A),1,0), if((C2:index(C:C,counta(C:C))<=eomonth(G2,sequence(1,datedif(G2,H2,"M")+1,0)))* (D2:index(D:D,counta(D:D))>=eomonth(G2,sequence(1,datedif(G2,H2,"M")+1,0))),E2:index(E:E,counta(E:E)),0)))
and here is the result -> [J1:U1]
Now, what i would need to do as the final step is to be able to group data by a certain label (John or Jane in the example) on separate rows, but mantaining the order/aggregate by month on the row. On the example, this would mean having one row with only 'John' data and below, one with 'Jane' values.
I am struggling to understand how to adapt the formula to do so.
I have tried:
Using another array to first return a list of these labels with query(unique()) or something like that, but then i struggle looping in it with the other formula.
A bit more simplistic but it could work after all: on the 1st row (the cell next to where the data will be returned) writing 'John', on row 2 'Jane' and then using filter() to only pull data that matches. The 'John, Jane' value is for the example but the real labels won't be that many, the list of labels don't need to be dynamic.
The thing with these solutions is that they work when used separately, but i can't figure out how to nest this in the first arrayformula() that Tom helped me with...As i am just beginning with the google sheets queries.
I don't really need necessarily the complete formula/code but maybe just directions or tips to visualize the way i could solve this.
Thanks to all who might contribute
With hindsight I might have done better to go down the route of using a query to calculate the sums on my previous answer rather than Mmult.
This uses the same method as before to create a 2d array of amounts vs dates (going across) and individuals (going down). Then it uses Textjoin to generate a query to group by name with the required number of columns.
=ArrayFormula(query({A2:A,if((C2:C<=eomonth(G2,sequence(1,datedif(G2,H2,"M")+1,0)))* (D2:D>=eomonth(G2,sequence(1,datedif(G2,H2,"M")+1,0))),E2:E,0)},
"select Col1,sum(Col"&textjoin("),sum(Col",,sequence(1,datedif(G2,H2,"M")+1,2))&") where Col1 is not null group by Col1"))
This is the generated query
select Col1,sum(Col2),sum(Col3),sum(Col4),sum(Col5),sum(Col6),sum(Col7),sum(Col8),sum(Col9),sum(Col10),sum(Col11),sum(Col12),sum(Col13) where Col1 is not null group by Col1
Ideally there should be an extra section saying label sum(Col2) '' etc. to suppress the 'Sum' headers.
=ArrayFormula(query({A2:A,if((C2:C<=eomonth(G2,sequence(1,datedif(G2,H2,"M")+1,0)))* (D2:D>=eomonth(G2,sequence(1,datedif(G2,H2,"M")+1,0))),E2:E,0)},
"select Col1,sum(Col"&textjoin("),sum(Col",,sequence(1,datedif(G2,H2,"M")+1,2))&") where Col1 is not null group by Col1 label sum(Col" & textjoin(") '', sum(Col",,sequence(1,datedif(G2,H2,"M")+1,2)) & ") ''"))

Search a range and bring back a stacked column of results

I know this is possible using a combination of probably =FILTER, ARRAYFORMULA and probably QUERY but hopefully, the examples will explain it better than words can.
Effectively, I have an output (the top table) and I want the formula that will bring back the dates each person has a mismatch (bottom table)
I hope that's clear enough.
try:
=ARRAYFORMULA(QUERY({A2:A10, TRIM(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(
IF(B2:G10="mismatch", B1:G1, )),,999^99)), " "))}, "where Col2 is not null", ))

Extract values from a range with 2 columns only if the value in column 1 contains a specific word in the column 2

I need to extract each individual person from a list that doesn't contain a certain activity (Project). Sounds easy but I can't quite get to the end of it.
Please check the example here on Sheet 2:
https://docs.google.com/spreadsheets/d/1qjbjXFCYj1qXrVVGNnhOj11asxT_o1xHWXerRqAl1UQ/edit#gid=2105763617
Here's the logic.
First I attempted to see if the individual only occurs once and if the Activity is not "Project"
=IF(A2<>"",IF(and(COUNTIF(A:A,A2)=1,B2<>"Project"),0,1),"")
Then I just extract the name that satisfies this criteria:
=query(ARRAYFORMULA(iF(I2:I=0,A2:A,"")), "where Col1 <>'' ")
This works, except there might be multiple assignments for the same person that does not contain the activity "Project" which my formula doesn't account for nor is it a simple dynamic arrayformula.
=UNIQUE(FILTER(A2:A, B2:B<>"Project"))
=UNIQUE(QUERY(A2:B, "select A where B <>'Project'", 0))
=UNIQUE(FILTER(A2:A, B2:B<>"Project",
NOT(REGEXMATCH(A2:A, "^"&TEXTJOIN("$|^", 1, FILTER(A:A, B:B="Project"))&"$"))))
While #player0's answer solves the question, it took a big performance hit on a sheet with >1000 rows.
Instead, I extracted all names that contained "Project" and then all names that did not contain "Project", then subtracted all the names from the first array to eliminate names that were in both.
=UNIQUE(FILTER(UNIQUE(FILTER(A2:A, B2:B<>"Project")), ISNA(MATCH(UNIQUE(FILTER(A2:A, B2:B<>"Project")), UNIQUE(FILTER(A2:A, B2:B="Project")),0))))
You may try this also:
{=IFERROR(INDEX($A$2:A$25,MATCH(0,IF($C$1<>$B$2:$B$25,COUNTIF($F$1:$F1,$A$2:$A$25), ""), 0)),"")}
N.B.
Cell C1 has criteria Project, using cell reference makes the formula
dynamic rather than hard coded.
Enter this formula in cell F2, finish with Ctrl+Shift+Enter,
and fill down.

IMPORTRANGE: value missing?

I have been working on this issue for a few weeks now and can't seem to find a solution. I used this answer (IMPORTRANGE with CONDITIONS) to get as far as I could, but I keep getting a value error.
This is the sheet I'm working with.
My goal is to use the first tab in the sheet (All Games) to enter all the games that I come across to create a compendium. But, then I want it to automatically populate the other tabs based on certain criteria (what type of game, skills learned, etc.)
On the Warm-Ups tab you'll see the formulas I have tried. A1 is the most recent.
Here is the formula I tried:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1F64PMg_iFu-DaJAUaE4BkpqF4zoteknp56VfwAUe8ag/edit#gid=1359689553", "All Games!A1:A1300"),"SELECT Col1 WHERE (Col2 = 'w') ")
I am getting a value error:
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: Col2
you are trying to reference Col2 but you selected range A1:A1300 which is just 1 column. therefore try:
=QUERY(IMPORTRANGE("1F64PMg_iFu-DaJAUaE4BkpqF4zoteknp56VfwAUe8ag", "All Games!A1:B1300"),
"SELECT Col1 WHERE (Col2 = 'w') ")
from the brief look on your sheet, you may want use matches or contains instead of = in your QUERY
You are only importing (part of) ColumnA - so no wonder Google can't find a second column :)

Resources