I'm trying to return a count of names from another sheet (it's a list of names in Column A and I want to pull the # of individual names into a cell in another sheet). I have many sheets with varying lists of names. I'm using the COUNTA(INDIRECT function, but I keep getting "1" as the result.
=COUNTA(INDIRECT("'"&A2&"'!A:A))")
Can anyone help?
You're nearly there, just have to move the last quote inside the brackets and remove the extra bracket.
=COUNTA(INDIRECT("'"&A2&"'!A:A"))
to account for errors such as "nothing to count" you will need:
=COUNTA(IFERROR(INDIRECT("'"&A2&"'!A:A")))
and btw that was the reason why you were getting 1 from your formula attempt because COUNTA counted the error.
Related
I have one spreadheet that includes name, id and amount of numbers data in it and i want to make the report in other spreadsheet.
i want to count the name column that is not blank, so i type this
=COUNTIF(importrange("gsheet link","Payroll 16-31 Jan!B3:B"),"<>")
but the result is "1" in fact that there are 3670 names on the column
=COUNTIF(importrange("gsheet link","Payroll 16-31 Jan!B3:B"),"<>"&"")
but still not working
can someone help?
I want to get the exact calculation of those data
Two things: have you connected the spreadsheets? If not, use IMPORTRANGE outside COUNTIF, something like =importrange("gsheet link","A1") . Accept the permissions and see if COUNTIF now does it right
If it doesn't, try with COUNTA that is specifically defined for counting non blank cells:. =COUNTA(importrange("gsheet link","Payroll 16-31 Jan!B3:B"))
A user pastes in a value to see if there is a full or partial match. I need to do a vlookup and keep removing characters until there is a match. A full match of something like test1.test2.test3 is no problem because it's a full match to my list. But if someone pastes in something like test1.test2.test3.test4, I need to remove a character one at a time from the end until there is a match. So in this example, it would match test1.test2.test3 and return that result.
Conceptually I see this as a for loop that counts the characters using len, using left to remove the number of characters from the end based on the current iteration, and doing vlookups until returning the value when true. But I'm not sure how to do this in Google Sheets.
This formula will give you the matching value that was found in the data(i.e. test1.test2.test3)
=FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data]))
This formula will give you the matching data and the cell reference where it was found (i.e. test1.test2.test3 # $A$4)
=FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data]))&" # "&CELL("address",INDEX([column_with_data],MATCH(FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data])),[column_with_data],0),1))
Simply copy & paste any of the above formulas next to the cell where users paste a value to look. Then, replace the two references in the square brackets [ ] with the proper coordinates in your sheet:
replace [column_with_data] with the coordinates of the column containing all the stored data (i.e. A1:A)
replace [cell_with_pasted_value_to_look] with the absolute ($col$row)coordinates of the cell where users paste the value to look (i.e. $B$1)
Would it be a problem to download the data from Google sheets, transform the file type to use the for loop in another software, and re-upload? I think your idea for a for loop would work.
It might be quicker if this is a long term project, but not so great if the client is continually monitoring/uploading.
My table contains 2 sheets with a different number of columns. I want to add a column that will display true or false (or any other 2 opposite values ) for each row depending on whether this row satisfies 2 criteria which are: sheet1!col1=sheet2!col1 and sheet1!col2=sheet2!col2.
You'll find an illustration below.
I've tried using
ARRAYFORMULA(VLOOKUP(A1&B1, {Sheet1!A1:A4&Sheet1!B1:B4,Sheet1!C1}, 3))
but I get an error message
vlookup evaluates to an out of bound range
So I wanted to try
QUERY({Sheet1!A1:B4,A1:B5}, "Select C where ")
but I couldn't figure out how to write the condition where (sheet1)col1=(sheet2)col1 & (sheet1)col2=(sheet2)col2 and I also don't know if I can work with tables of different dimensions. I finally tried
=MATCH(A1&B1,{Sheet1!A1:A&Sheet1!B1:B})
but it always returns 1.
Any idea please?
Sheet 1
Sheet 2
Your first formula is almost right. You are getting the error message because there is only one column in the curly brackets so you have to change it to
=ArrayFormula(vlookup(A1&B1,{Sheet2!A:A&Sheet2!B:B},1,false))
and add the 'false' to make sure it only does exact matches.
To make the query work you need the right syntax to access cells in the current sheet:
=query(Sheet2!A:B," select A,B where A='"&A1&"' and B='"&B1&"'")
To make the match work, you need to enter it as an array formula and add a zero to specify exact match:
=ArrayFormula(MATCH(A1&B1,{Sheet2!A:A&Sheet2!B:B},0))
However I would take flak from my colleagues if I didn't point out that there is an issue with the vlookup and match as shown above - toto&moto would match with not just toto&moto, but also with tot&omoto etc. The way round this is to add a separator character e.g.
=ArrayFormula(vlookup(A1&"|"&B1,{Sheet2!A:A&"|"&Sheet2!B:B},1,false))
=ArrayFormula(MATCH(A1&"|"&B1,{Sheet2!A:A&"|"&Sheet2!B:B},0))
These still need some tidying up if they are to report Yes and No, and also not to give false positive on blank rows - also the vlookup and match can be written as self-expanding array formulas - but that is the short answer to the question.
Use case
Sort formula against other sheet but exclude empty values after last item. Empty values get sorted at top, creating a whole bunch of blank space, and then data I care about.
=SORT('other sheet'!A1:C36,'other sheet'!D1:D36,FALSE)
A-C is the data I wish to show.
D is the column I wish to sort on.
Problem
The "36" must be manually updated each time I add/remove a row to 'other sheet'.
Possible solution would be:
Get the row number of the last non-empty cell in a column in Google Sheets as [last row].
=SORT('other sheet'!A1:C[last row],'other sheet'!D1:D[last row],FALSE)
What I tried
Lookup("",'other sheet'!A:A)
Result: #N/A
No examples in Help for finding empty cells
Get the last non-empty cell in a column in Google Sheets
Returns value not address. Could find that value in row but not as efficient. Also what if value is found in more than one place?
** Example Speadsheet **
https://docs.google.com/spreadsheets/d/1bqiVe3pBYDJFtrO4EysSKTDq17lzY5r2b8sPV-KnTdI/edit#gid=0
I cannot recreate this in a new spreadsheet. I believe this may be a bug.
If you want to find the last row, you can use the following formula.
=SORT(INDIRECT("'other sheet'!A1:C"&QUERY(TRANSPOSE(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A="")),"select Col1")),INDIRECT("'other sheet'!D1:D"&QUERY(TRANSPOSE(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A="")),"select Col1")),FALSE)
The code in bold is a formula to find the first blank cell in column A in 'other sheet'.
The code in italic return a reference range based on the bolded code.
I hope this help even though it seems to be a very long time since your question.
Edited: I just found out that query can limit rows.
=SORT(INDIRECT("'other sheet'!A1:C"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),INDIRECT("'other sheet'!D1:D"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),FALSE)
Edited: Sorry, I didn't read the question carefully. If you want to remove the first blank cell when sort in descending order, you just have to simply add a QUERY function at front, without query for anything.
=QUERY(SORT(INDIRECT("'other sheet'!A1:C"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),INDIRECT("'other sheet'!D1:D"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),FALSE),"")
I'm trying to count bus headways --the number of minutes between bus arrivals--in Google Sheets. The arrivals are written as 0:00, 1:00,2:00, etc... I want to count the number of instances of zero-minute buses, one-minute buses, etc..
When I try this =countif(range,"0:00"), I get "0:00" as an answer. What am I doing wrong?
Change the formatting of the range to text and then try
=countif(range, "*:00")
Maybe try using a Pivot Table:
One option is to use a helper column along with ISNUMBER and SEARCH.
Let's say your data is in A1:A3. In B1, you could put =ARRAYFORMULA(IF(ISNUMBER(SEARCH(":",A1:A))=TRUE,1,"")).
That searches for ":" in column A. If the statement evaluates to TRUE then a 1 is placed in the corresponding row. If it evaluates to FALSE then nothing "" is entered.
Then in C1 you could put =SUM(B1:B).