Counting Cells with Specific Strings Row by Row (IF AND Statement?) - google-sheets

Summary
Goal: count cells that contain specific strings in columns A AND B checking each pair of rows in the columns.
What I have So Far: =IF(AND(B3="GA", C3="Grocery"), COUNTIF(C3, "Grocery"),0)
What I Need: how to specify continuing this process for each pair of rows in columns A and B.
Context: counting business in different states that have been assigned specific categories. For example, how many businesses in Georgia ("GA") are categorized as "Grocery"?
Example Google Sheet
Details
I am creating a function with the goal of checking cells in columns A and B in the same row to match a specific string for each, adding +1 to the count if they both match, then checking the next row in columns A and B. How can the function be written to continue checking all of columns A AND B row by row?
Thank you!

Try something like-
=BYROW(FILTER(B3:C,C3:C<>""),LAMBDA(x,IF(AND(INDEX(x,1,1)="GA",INDEX(x,1,2)="Grocery"),COUNTIFS(C3:C,"Grocery"),"")))
Or try-
=BYROW(B3:C,LAMBDA(x,IF(AND(INDEX(x,1,1)="GA",INDEX(x,1,1)<>"",INDEX(x,1,2)="Grocery"),COUNTIFS(C3:C,"Grocery",B3:B,"GA",INDEX(ROW(C3:C)),"<="&ROW(x)),"")))

As per sample sheet provided in comment, you can try this formula.
=COUNTIFS(C3:C,E16,B3:B,"GA")

try:
=INDEX(IF((B3:B="GA")*(C3:C="Grocery"),
COUNTIFS(C3:C, "Grocery", ROW(C3:C), "<="&ROW(C3:C)), 0))

Related

Unnest two columns in google sheet

I have a table like this one here (basically it's data from a google form with multiple choice answers in column A and B and non-muliple choice data in column C) I need a separate row for each multiple choice answer.
Column A
Column B
Email
A,B
XX,YY
1#gmail.com
A,C
FF,DD
2#gmail.com
I tried to un-nest the first column and keep the remaining columns like this
enter image description here
I tried several approaches I found with flatten and split with array formulas but I don't know where to start really.
Any help or hint would be much appreciated!
You can use the split function on the column A and after that, use the index function. Considering the table, you can use:
=index(split(A2,","),1,1)
The split function separate the text using the delimiter indicated, returning an array with 1 line and 2 columns; the index function will return the first line and the first column from this array. To return the second element from the column A, just change to
=index(split(A2,","),1,2)
I think there's no easy solution for this. You're asking for as many combinations of elements as multiple-choice elections have been made. Any function in Google Sheets has its potentials and limitations about how many elements it can express. One very useful formula here is REDUCE. With REDUCE and sequences of elements separated by commas counted with COUNTA, you can stablish this formula:
=QUERY(REDUCE({"Col A","Col B","Email"},SEQUENCE(COUNTA(A2:A)),LAMBDA(z,c,{z;LAMBDA(ax,bx,
REDUCE({"","",""},SEQUENCE(ax),LAMBDA(w,a,
{w;
REDUCE({"","",""},SEQUENCE(bx),LAMBDA(y,b,
{y;INDEX(SPLIT(INDEX(A2:A,c),","),,a),INDEX(SPLIT(INDEX(B2:B,c),","),,b),INDEX(C2:C,c)}
))})))
(COUNTA(SPLIT(INDEX(A2:A,c),",")),COUNTA(SPLIT(INDEX(B2:B,c),",")))})),
"Where Col1 is not null",1)
Since I had to use a "initial value" in every REDUCE, I then used QUERY to filter the empty values:

Google Sheets - get value from above

I'm trying to work out a function in a Google Sheets cells to look at a column then search current row and "above" the current row to find a non number value (text).
I have data that in two columns B (item code or category) & C (item description).
I need another column to contain the categories for each item - column D. I'm looking for a formula for this column, ideally an Arrayformula as the data can change, there can be multiple items per category, some might be only 1 item, some might be 100 items per category. The arrayformula in column D will get the category from column B if it is not a number.
B column - categories and item codes, C column - item descriptions, target is D column a copy of the categories from column B.
I've tried this numerous times and usually give up, do it manually but it becomes teadious quickly. Looking forward to any help that might come from this! thanks.
In D2 try
=Arrayformula(if(isnumber(B2:B), vlookup(row(B2:B), filter({row(B2:B) , B2:B}, istext(B2:B)), 2), B2:B))
and see if that works?
Try in D1
={"Category";ArrayFormula(lookup(row(B2:B),row(B2:B)/if(isnumber(B2:B),0,1),B2:B))}

How to get row List elements compare by two rows Google Sheets

I have spreadsheet https://docs.google.com/spreadsheets/d/1qjvn90lZ7AWhYApChd2gAKHzZqmnNz4xlURENSQasaw/edit#gid=0 and i want to get rows with some differences by unique values Id and Updated at.
List №1 i have the same automatic importing data http://prntscr.com/t3axvt
In List №3 i try to use =UNIQUE('List1'!A2:A;'List1'!D2:D) http://prntscr.com/t3ayx8 but it didn't work
Question
i need to get rows from List1 if there are duplicates with these parameters Id and Updated at first row from duplicate rows (must be like this http://prntscr.com/t3b3nb) or last row from duplicate rows (must be like this http://prntscr.com/t3b3nb).
You can create a helper column to achieve this
Create a helper column J and put the below formula in J2
=arrayformula(if(D2:D7=OFFSET(D2:D7,-1,0),"",ROW(A2:A7)))
Then you'll be able to filter your data, put below formula in A10
=FILTER(A2:J7,J2:J7<>"")
Please amend your data ranges per your requirement
Please use ; instead of , if you in are different continent
for Extended Range, use below formula
=arrayformula(if(D2:D="","", if(D2:D=OFFSET(D2:D1000,-1,0),"",ROW(A2:A))))

Google Spreadsheets: Formula to "interleave" or "zipper" multiple arrays

Tried searching and checking Google documentation but I am still having issues getting the results that I want for this problem.
I'm needing to split several comma-separated lists of items and recombine them so that first items in each list is combined, followed by the second item, etc.
To ask with an illustration, if I have a cell with the following
Paul, John, George, Ringo
and another cell with the following
McCartney, Lennon, Harrison, Starr
How do I use one function to produce this in a cell?
Paul McCartney, John Lennon, George Harrison, Ringo Starr
Here you go, you will need to copy to every row - but assuming your data is in columns A and B it will work across a dynamic number of items:
=ARRAYFORMULA(join(",",split(A1,",")&" "&split(B1,",")))
See image example below, in row one i used the data you showed up top, and in row two i reversed the column data just to show as an example:
If you paste the first word CSV to Sheet1 and the second word CSV to Sheet2 then you could put the following into sheet3
In Cell A1:
=Sheet1!A1&" "&Sheet2!A1
This is saying take the value in sheet1 A1 and then a space " " then the value in sheet2 A1
You could also do this with the concatenate function:
=CONCATENATE(Sheet1!A1," ",Sheet2!A1)
Then just copy the formula to suit.

Count number of cells with any value (string or number) in a column in Google Docs Spreadsheet

I have several columns in Google Spreadsheet.
I would like to count how many cells have a value (number or string) and display that number at the top of the column.
For example:
Hello
World
123
Some string
The above column would give me the answer of "4"
I have not managed to find a formula that does this.
In the cell you want your result to appear, use the following formula:
=COUNTIF(A1:A200,"<>")
That will count all cells which have a value and ignore all empty cells in the range of A1 to A200.
You could also use =COUNTA(A1:A200) which requires no conditions.
From Google Support:
COUNTA counts all values in a dataset, including those which appear
more than once and text values (including zero-length strings and
whitespace). To count unique values, use COUNTUNIQUE.
An additional trick beside using =COUNTIF(...) and =COUNTA(...) is:
=COUNTBLANK(A2:C100)
That will count all the empty cells.
This is useful for:
empty cells that doesn't contain data
formula that return blank or null
survey with missing answer fields which can be used for diff criterias
Shorter and dealing with a column (entire, not just a section of a column):
=COUNTA(A:A)
COUNTA
Beware, a cell containing just a space would be included in the count.
The SUBTOTAL function can be used if you want to get the count respecting any filters you use on the page.
=SUBTOTAL(103, A1:A200)
will help you get count of non-empty rows, respecting filters.
103 - is similar to COUNTA, but ignores empty rows and also respects filters.
Reference : SUBTOTAL function

Resources