Using COUNTIFS in Google Sheets with a possible blank criteria - arrays

Ok so I'm sure there is a way to do this, I am just not sure how to do it. Say I have 3 columns. Column A contains a "A" or "B", column B contains "1" or "2" and column C contains "!" or "?". I have separate cells in which I use to filter what I am looking for. I want to find each time a certain instance when all 3 character that I pick show up. D1 is where I choose "A" or "B", D2 is where I choose "1" or "2" and D3 is where I choose "!" or "?". I have a formula to find where if I choose say A, 1, !, it counts how many times all three of those appear in the same row. Now I want to leave one of the Cells blank (say D1) and only calculate how many times "1" and "!" appear together and not worry about "A" or "B" in the first column. Is there any way to do this? My current equation is just a long COUNTIFS equation that checks row A against cell D1, row B against D2 and row C against D3. Is there any way to use this equation but ignore one of the conditions if a cell is blank?
Sorry for the rambling and poor formatting. I hope this makes sense!

Now you can combine the criteria (1,2 or 3):
= countif
(
filter
(
if ( D2 = "" , left("", row($A$2:$A)^0), $A$2:$A) &
if ( D3 = "" , left("", row($B$2:$B)^0), $B$2:$B) &
if ( D4 = "" , left("", row($C$2:$C)^0), $C$2:$C)
, $A$2:$A <> ""
)
, "=" & D2 & D3 & D4
)

try:
=COUNTIFS(A:A, IF(E3="", "<>"&E3, E3), B:B, E4, C:C, E5)
for full independency you can do:
=COUNTIFS(A:A, IF(E3="", "<>"&E3, E3),
B:B, IF(E4="", "<>"&E4, E4),
C:C, IF(E5="", "<>"&E5, E5))

Related

ISBLANK(...) = FALSE even thought the cell is blank in google sheet

Hi everyone,
I have 2 tables, 3rd column for Table 1 is Value 1 and 3rd column for Table 2 is Value 2. I combined these 2 tables by expanding both tables first so that all the columns are aligned as shown in the screenshot above (Column E to Column H).
The formula in all the yellow cells are:
Cell E4 : =QUERY(A4:C10,"Select A,B,C,' ' label ' ' 'Value 2' ")
Cell E12 : =QUERY(A12:C20,"Select A,B,' ',C label ' ' 'Value 1' ")
Cell K7 : =QUERY({E5:H10;E13:H17},"Select * where Col1 is not null",0)
Cell P7 : =ArrayFormula(IF(ISBLANK(M7:M12),100,M7:M12))
In column P, I want to return 100 as Value 1 if the cells in Column M is blank. So by right I should get 2,34,55,100,100,100 in column P but right now the formula still return 3 blank cells.
I suspect that is because the QUERY function that I used before which make the cell is not blank although it seems like still a blank cell. May I know is there any trick that I can use to find the blank cells in column M and column N (preferably don't touch the QUERY formula) since ISBLANK() is not working in this case?
Any help or advise will be greatly appreciated!
Edited
makes sense. you cant use ISBLANK because cell is not blank. remember that QUERY inserted an empty space.
try:
=ARRAYFORMULA(IF(ISBLANK(TRIM(M7:M12)), 100, M7:M12))
ISBLANK is so sensitive that it will detect even residue from TRIM
update:
=ARRAYFORMULA(IF(TRIM(M7:M12)="", 100, M7:M12))

Vlookup on multiple values in a cell

I would like to be able to return [cat,dog] as shown in column B. This is more of a POC, but for the main challenge I am facing, there will be an unknown number of values in cell A1. I'm not sure if there is a way to do this with a vlookup, or if there is a better way to do this.
Guessing there could be more then one canine species (dog, dog2, ...) and all should be returned:
= "["
& JOIN(
",",
QUERY(
A3:B11,
"SELECT B
WHERE A MATCHES '^(?:" & JOIN("|", UNIQUE(SPLIT(A1, "[,]"))) & ")$'
ORDER BY B",
0
)
)
& "]"
We just filter out everything that does not match the regular expression ^feline|canine|...$ with QUERY using MATCHES and join it with commas.
Regular expression is constructed in this (just unique words joined by |):
'^(?:" & JOIN("|", UNIQUE(SPLIT(A1, "[,]"))) & ")$'
use:
=ARRAYFORMULA("["&TEXTJOIN(",", 1,
IFERROR(VLOOKUP(FLATTEN(SPLIT(A1, "[,]", 1, 0)), A3:B, 2, 0)))&"]")

If blank return 0 else run vlookup

I would like to use the vlookup function to match two criteria values firstly based on the value selected in a dropdown menu (country) and the value in A2(name). If the value in A2 Sheet matches the one of the values in the A column in Sheet2 and the value of the dropdown menu in Sheet1 matches one of the values in Sheet2 Column D (Which is a concatenation of the name and country) I would like to return the corresponding value in Sheet2 ColumnC.
If the value is 0 or blank I would like to return 0.
This is what I have tried
=ARRAYFORMULA(
IF(
ISBLANK(
IFERROR(VLOOKUP(A2&C2,Sheet2!$A$2:$E$61,3,1),"0"))))
Not sure what I might be doing wrong
Here is a sample of my data
Sheet 1:
A B C
name1 (vlookup) [dropdownmenu]
and Sheet 2
A B C
name1 val concatenationofA&B
Here is a test sheet as requested:
https://docs.google.com/spreadsheets/d/1jsFnaGY7N9nXyPs5vR32jG5G838w1SgB2XIad7bEFXg/edit?usp=sharing
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A&C2:C, {Sheet2!A2:A&Sheet2!B2:B, Sheet2!C2:C}, 2, 0), 0))
I managed to resolve this using the query function
=QUERY(Sheet2!$A$2:$E$61,"select C where B = """&C12&""" and A = """&A12&""" ")
The only problem is I don't know how to suppress NA values/replace them with the value 0

color first five rows of a table in SSRS

Iam developing a report where I need to provide special effects on 1st few columns. How can I color code or provide 3D effect for first five rows of a table in SSRS? Also, count of values in these columns?
For example:
My date count
A 3
B 4
C 1
D 1
E 5
F 6
G 7
Now, I should color rows start from A to E and get total count of that ( e.g. 14 in this case)
How can I I acheive this?
While Strawberryshrub's answer would probably work just fine, there's an easier way that can get you the same result. You should be able to use the SSRS function RowNumber to indicate which rows should be colored. Try the following expression in the background color property for that row.
=IIF(RowNumber(Nothing) < 6, "Green", "No Color")
Also, for the count that you need, you should be able to use a similar pattern.
=SUM(IIF(RowNumber(Nothing) < 6, Fields!count.Value, 0))
One possible option is to cathegorize your first column with an calculated field:
'Name: CustomCathegory
=IIF(Fields!MyDae.Value = "A" Or
Fields!MyDae.Value = "B" Or
Fields!MyDae.Value = "C" Or
Fields!MyDae.Value = "D" Or
Fields!MyDae.Value = "E", "Cathegory1", "CathegoryElse")
Now you can use the row coloring (font or background) and use the following expression:
=IIF(Fields!CustomCathegory = "Cathegory1", "Blue", "Black")
You can also sum by CustomCathegory (textbox outside the detail section)
=Sum(IIF(Fields!CustomCathegory = "Cathegory1", Fields!Count.Value, 0))
or group your table by CustomCathegory and add header or footer with the sum per CustomCathegory

3 part formula for linking string data from different / same cell

A1
Michael Lewis
B1
'at'xyz
I would like an individual formula to do each of the following
Michael.lewis#xyz.com (First Name ‘dot’ Surname)
M.lewis#xyz.com (First initial ‘dot’ Surname)
mlewis#xyz.com (First initialSurname)
Id like a drop down menu to change which formula I am using.
Is this possible?
I'm not sure if I get exactly what you need, but here goes.
I had to translate all the formulas back to english because my work computer is in a different locale but I think it's right (in case there's a typo I missed)
The formulas you asked for in respective order:
(B11 = name, B12 = email domain)
=LEFT(B11;SEARCH(" ";B11)-1) & "." & RIGHT(B11; LEN(B11)-SEARCH(" ";B11))& "#" &B12
=LEFT(B11;1) & "." & RIGHT(B11; LEN(B11)-SEARCH(" ";B11))& "#" &B12
=LEFT(B11;1) & RIGHT(B11; LEN(B11)-SEARCH(" ";B11))& "#" &B12
Then you can just add a data validation list pointing to the cells you write the formulas on and it should work as intended, I hope.
Accessing first name in cell A1:
= LEFT(A1,FIND(" ",A1)-1)
Accessing last name in cell A1:
= RIGHT(A1,FIND(" ",A1)-1)
Accessing first initial in cell A1:
= LEFT(A1,1)
Getting passed the 'at' in cell B1 and only returning xyz:
= RIGHT(B1,5)
Therefore, for example, <first name>.<last name> is:
= LEFT(A1,FIND(" ",A1)-1)&"."&RIGHT(A1,FIND(" ",A1)-1)&"#"&RIGHT(B1,5)&".com"
If you remove the 'at' from cell B1 and just have xyz, then the formula above could be slightly simplified; You can substitute RIGHT(B1,5) simply with B1.
Also, the LOWER function converts all text to lowercase.
For example to get the lowercase first letter of first name, formula would be:
= LOWER(LEFT(A1,1))

Resources