I have the formula written below. On the condition where Column E = "EPIs", there is a second condition to verify if Column G contains the string ("CC", "Hemo" or "odonto").
But that second condition is not returning correctly the 'contains the specified string' part.
It gets true for Col E = "EPIs", but false for the second cases.
How can I make it work?
=ARRAYFORMULA(
IF(B3:B="";"";
IF(M3:M="";"Verificar";
IF(M3:M="Realizado - Sem Certificado";"Verificar";
IF(M3:M="Manutenção";"Verificar";
IF(M3:M="Verificar";"Verificar";
IF(M3:M="Verificar se está ativo";"Verificar";
IF(M3:M="Não realizado";"Verificar";
IF(M3:M="Desativado";"DESATIVADO";
IF(E3:E="EPIs";
(IF(G3:G="*CC*";IF(DATE(YEAR(M3:M);MONTH(M3:M)+6;DAY(M3:M))>TODAY();IF(DATE(YEAR(M3:M);MONTH(M3:M)+4;DAY(M3:M))>TODAY();"OK";"Realizar CQ");"Vencido");
IF(G3:G="*hemo*";IF(DATE(YEAR(M3:M);MONTH(M3:M)+6;DAY(M3:M))>TODAY();IF(DATE(YEAR(M3:M);MONTH(M3:M)+4;DAY(M3:M))>TODAY();"OK";"Realizar CQ");"Vencido");
IF(G3:G="*odonto*";IF(DATE(YEAR(M3:M)+2;MONTH(M3:M);DAY(M3:M))>TODAY();IF(DATE(YEAR(M3:M)+2;MONTH(M3:M)-2;DAY(M3:M))>TODAY();"OK";"Realizar CQ");"Vencido");
IF(DATE(YEAR(M3:M)+1;MONTH(M3:M);DAY(M3:M))>TODAY();IF(DATE(YEAR(M3:M)+1;MONTH(M3:M)-2;DAY(M3:M))>TODAY();"OK";"Realizar CQ");"Vencido")
))));
IF(E3:E="Odonto Intra";IF(DATE(YEAR(M3:M)+2;MONTH(M3:M);DAY(M3:M))>TODAY();IF(DATE(YEAR(M3:M)+2;MONTH(M3:M)-2;DAY(M3:M))>TODAY();"OK";"Realizar CQ");"Vencido");
IF(DATE(YEAR(M3:M)+1;MONTH(M3:M);DAY(M3:M))>TODAY();IF(DATE(YEAR(M3:M)+1;MONTH(M3:M)-2;DAY(M3:M))>TODAY();"OK";"Realizar CQ");"Vencido") ) ))))))))))
The formula you wrote is quite a bit more convoluted than you needed it to be.
I think using EDATE() and LOOKUP() you can achieve the desired effect more easily.
=ARRAYFORMULA(IF(M3:M="";;LOOKUP(TODAY()-EDATE(M3:M;IF(REGEXMATCH(G3:G;"Hemo|CC");6;IF(REGEXMATCH(G3:G;"Odonto");24;12)));{-9^9;-60;0};{"OK";"Realizar";"Vencido"})))
new as heck here and I trying to find the best way to further optimize a set of sheets functions.
The starting function was essentially 26 stacked filter functions being used to reference individual cells beneath containing names(strings), find the IDs associated with the names in these cells, pull the IDs from the "ref" sheet, and create a url that contains these IDs. The function, stripped of confidential data:
=HYPERLINK(CONCATENATE("https://url.com/stuff?ids=",if(isna(filter(ref!$B:$B,ref!$A:$A=B3))=true,"",filter(ref!$B:$B,ref!$A:$A=B3)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B4))=true,"",filter(ref!$B:$B,ref!$A:$A=B4)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B5))=true,"",filter(ref!$B:$B,ref!$A:$A=B5)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B6))=true,"",filter(ref!$B:$B,ref!$A:$A=B6)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B7))=true,"",filter(ref!$B:$B,ref!$A:$A=B7)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B8))=true,"",filter(ref!$B:$B,ref!$A:$A=B8)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B9))=true,"",filter(ref!$B:$B,ref!$A:$A=B9)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B10))=true,"",filter(ref!$B:$B,ref!$A:$A=B10)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B11))=true,"",filter(ref!$B:$B,ref!$A:$A=B11)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B12))=true,"",filter(ref!$B:$B,ref!$A:$A=B12)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B13))=true,"",filter(ref!$B:$B,ref!$A:$A=B13)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B14))=true,"",filter(ref!$B:$B,ref!$A:$A=B14)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B15))=true,"",filter(ref!$B:$B,ref!$A:$A=B15)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B16))=true,"",filter(ref!$B:$B,ref!$A:$A=B16)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B17))=true,"",filter(ref!$B:$B,ref!$A:$A=B17)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B18))=true,"",filter(ref!$B:$B,ref!$A:$A=B18)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B19))=true,"",filter(ref!$B:$B,ref!$A:$A=B19)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B20))=true,"",filter(ref!$B:$B,ref!$A:$A=B20)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B21))=true,"",filter(ref!$B:$B,ref!$A:$A=B21)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B22))=true,"",filter(ref!$B:$B,ref!$A:$A=B22)),"&morestuff=true"),"Group A")
The best I could do to optimize this was to compile the IDs in one cell (B1) with this QUERY function within a TEXTJOIN:
=TEXTJOIN(",",TRUE, QUERY(ref!$A$2:$B, "select B where A = '"&B3&"' or A = '"&B4&"' or A = '"&B5&"' or A = '"&B6&"' or A = '"&B7&"' or A = '"&B8&"' or A = '"&B9&"' or A = '"&B10&"' or A = '"&B11&"' or A = '"&B12&"' or A = '"&B13&"' or A = '"&B14&"' or A = '"&B15&"' or A = '"&B16&"' or A = '"&B17&"' or A = '"&B18&"' or A = '"&B19&"' or A = '"&B20&"' or A = '"&B21&"' or A = '"&B22&"' or A = '"&B23&"' or A = '"&B24&"' or A = '"&B25&"' or A = '"&B26&"' or A = '"&B27&"' or A = '"&B28&"' or A = '"&B29&"' "))
Then do the url generation in another cell (B2), referencing B1 for the IDs:
=HYPERLINK(CONCATENATE("https://url.com/stuff?ids=", ",", B1, "&morestuff=true"), "Group A")
I then copied these across Groups B-Z
I tried multiple variations of FILTER stacked in ARRAYFORMULA but I couldn't get it to work. I'm unsure if there is a syntax I should be using to better handle matching text that I am not quite figuring out. Simply matching by first letter is not an option as there are names that do not qualify for the groupings contained within the "ref" sheet for use in other data sets.
So my question here is really: is there an easier way to compile this where I don't have to reference each cell individually for matches on the "ref" sheet?
For an example of the sheet I am working with, this link should work:
https://docs.google.com/spreadsheets/d/1ykSldWyQnPcar9G21ljLOzm3dWC1i82kMaQJuSKHajc/edit?usp=sharing
Just use another textjoin to construct your query string as follows:
="select B"&if(counta(B3:B)=0,""," where A='")&textjoin("' or A='",true,B3:B)
Not only is this much shorter than manually typing each cell but it will also expand infinitely downward as required.
=arrayformula(UNIQUE(
{
IFERROR(FILTER('New Bets'!A3:H,'New Bets'!I3:I<>""),{"","","","","","","",""})
;
IFERROR(FILTER(Alertas!A2:H101,Alertas!I2:I101<>""),{"","","","","","","",""})
}))
=UNIQUE(A3:H)
When I use Unique separately from the rest of the formula, it correctly returns only one row with data, without duplicates. But when using inside the formula, it returns two equal values.
I wonder what I'm doing wrong.
Link to Spreadsheet:
https://docs.google.com/spreadsheets/d/1sv1B1mYrhpzS-ZtCLfLkVPtbffWq231woEX_qOxiAXA/edit?usp=sharing
try:
=ARRAYFORMULA(UNIQUE(TRIM(
{IFERROR(FILTER('New Bets'!A3:H,'New Bets'!I3:I<>""),{"","","","","","","",""});
IFERROR(FILTER(Alertas!A2:H101,Alertas!I2:I101<>""),{"","","","","","","",""})})))
Google Spreadsheets: I am trying to match multiple variables in multiple columns
I have tried this code
=match(T7&C7&"v";T$2:T6&C$2:C6&K$2:K6)
that I expected would woork, but it does not .... any ideas how I can do this?
Try this:
=ARRAYFORMULA(match(T7&C7&"v",ARRAYFORMULA(TRANSPOSE(Split(CONCATENATE(T$2:T6&C$2:C6&K$2:K6&"|"),"|"))),0))
If this does not work, please give us an example of your data
This is the final formula
=if(D2<>""; vlookup(arrayformula(MAX(( T$1:T1 = T2 )*4 + ( C$1:C1 = C2 )*2 + ( K$1:K1 = "✓" )*1));Lookup!D:E;2);"")
First check if cell empty
Then find mathcing values above the current row, start with most
important first
Then verify/code-label the results (7 = full match, 6 = site +
link, 4 = only site)
Setup a lookup table to translate the results to values you
understand