COUNTIF text query with offset in google sheet - text

I have this file with 3 different sheets.
The first contains the raw data, the second (stats) a first step of analysis and the last (WEEKLY) shows my final extrapolation.
In the WEEKLY sheet, B14 and B15, I want to count the rows from the raw data sheet that, in column G, have an "L" and a "S".
I used:
=COUNTIF(offset(data!$G$3,COUNT(data!$G$3:$G)-B2,0,B2,1),"L")
but it does not work.
I used exactly the same syntax to show positive and negative based on column R:
=COUNTIF(offset(data!$R$3,COUNT(data!$R$3:$R)-B2,0,B2,1),"<=0")
and it works pefectly as shown in the sheet WEEKLY, B9 and B10.
I can easily count Ls and Ss with a simple formula like:
=countif(G1:G1257,"=L")
but I need all the offset thinghy...
My question is:
How can I count the S and L in the G column of the data sheet maitaining the same offset fuction I used to count positive and negative on the R column?

Your formula with column R works with COUNT because the values in column R are numeric and COUNT counts cells which contain numbers.
It doesn't work with column G because it contains text so you need to use COUNTA
=COUNTIF(offset(data!$G$3,COUNTA(data!$G$3:$G)-B2,0,B2,1),"L")

Related

How to use SUMIF in an array formula to not sum blank rows

Hi I am using the following array formula to sum rows AC-AG , I would like to modify it so that it does not sum if an entire row is blank. How would I do this using an array formula since this spreadsheet is tied to a google forum and gets updates often.
I am using this formula at the top of the column.
={"# Boxes of Household Items"; ARRAYFORMULA(SUMIF(IF(COLUMN(AC1:AG1),ROW(AC2:AG)),ROW(AC2:AG),AC2:AG))}
Example Below
The Formula adds up AC through AG and puts them in AR.
I want the formula to not put a zero in AR5 since the entire row is blank
In the image above I have numbers in various cells from columns A:E, then I have a formula in cells F1:F3.
Row 1 has numbers for all cells.
Row 2 has numbers for some cells.
Row 3 has no numbers.
To show the sum when all/some of the cells contain numbers, I would do:
=IF(COUNT(A1:E1)>0,SUM(A1:E1),"")
We check IF there is at least one number using COUNT(A1:E1)>0. If there is at least one number, we then show the sum using SUM(A1:E1) otherwise we just show nothing, which is the "" part.
For you the formula would be this in AR2:
=IF(COUNT(AC2:AG2)>0,SUM(AC2:AG2),"")

Excel lookup for single and multiple criteria together

I have 10000 rows of data in excel in column A & B and a new sheet with all data from column A. What i want to do a VLOOKUP from sheet 1 to sheet 2. But there are few examples in column A with 2 values in B.
Example:
Sheet 1
In sheet 2 if VLOOKUP is done for orange I am expecting 20,30
I have tried single criteria =VLOOKUP(A2,sheet2!a1,false) which worked for apple
Any suggestions how both the expected results can be done together
Not sure if it helps, but here's a solution with the formula:
Array formula in cell E2 (Ctrl+Shift+Enter):
=SUMPRODUCT(LARGE((--(IF(LEN($A$2:$A$6),$A$2:$A$6,OFFSET($A$2:$A$6,-1,0))=$D2))*($B$2:$B$6),1))
In column F you need to replace "1" (at the very end of the formula) with number "2".
A few notes:
your data set cannot start in row 1, otherwise OFFSET formula won't work.
both formulas (columns E & F) are looking for the 1st and 2nd largest number which matches the argument (column D). If the second one doesn't exist, it returns 0.
However, given the size of your data set, it is worth considering a VBA solution.
Edit: adjusted for column B = text
Use the following Array formula in cell E2 (Ctrl+Shift+Enter):
=IFERROR(INDEX($B$2:$B$6,SUMPRODUCT(LARGE((--(IF(LEN($A$2:$A$6),$A$2:$A$6,OFFSET($A$2:$A$6,-1,0))=$D2))*(ROW($B$2:$B$6)),1)-1)),"")
Similar Array formula in cell F2 (Ctrl+Shift+Enter):
=IFERROR(INDEX($B$2:$B$6,SUMPRODUCT(LARGE((--(IF(LEN($A$2:$A$6),$A$2:$A$6,OFFSET($A$2:$A$6,-1,0))=$D2))*(ROW($B$2:$B$6)),2)-1)),"")
Result:

CountIf not counting values derived from formula

I couldn't find a matching answer already but happy to be redirected!
My issue is with countifs across two worksheets but I can replicate it in a smaller environment.
I have three columns of data (A-C): -
Column D has the formula =IF(A2="Closed",C2-B2,0).
That bit works, I now need to count how many took X number of days to close: -
Column G has the formula =COUNTIFS(A2:A11,"Closed",D2:D11,F2)
Looking at the pictures 41 and 49 should have a count of 1 right? What have I done wrong? All cells are formated as numbers.
Your formula in column G uses an absolute comparison to the value in column F.
The problem is that none of your values exactly match that value.
The duration column is formatted to show a value rounded to a day, but the underlying value is not the same as what is showing in the formatted cell.
Therefore, the formula in column G needs to factor in a range of values like this:
=COUNTIFS($A$2:$A$11,"Closed",$D$2:$D$11,">="&F2,$D$2:$D$11,"<"&F3)
In words: count all the cells where column A shows "Closed" and where the value in column D is between the value in F2 and the value in F3.
You will need to add an extra value in column F for anything above your biggest number in column F.
Check you output in Column D. It must be having decimals. If that is the case, you need to round the formulas in column D using ROUND formula.
=ROUND(IF(A2="Closed",C2-B2,0),0)
Rows 4 and 7 have status as "Open" and hence won't be counted by Countifs, i. e. change value of cells A4 and A7 to "Closed" to see updated results.
Also, fix your range $A$2:$A$11, etc. when using Countifs

excel: Find value in column where cells contain multiple values separated by commas and return value from an adjacent column

I have two tables of data, call them table 1 and 2. In table 1 there is a long list of reference numbers. Each reference number has its own cell.
In table 2 I have the exact same reference numbers; however, in table 2 these reference numbers may or may not share that cell with another reference number. See below. The bottom three reference numbers in table 1 all share the same cell and are separated by a comma always.
Imagine table 1 and 2 are on separate tabs of the same workbook.
table 1 and 2
On the work sheet for table 1, I am trying to bring back the month found adjacent to the reference number in table 2. I am trying to take the value in table 1, search it in table 2, and return the month so that I get this result:
result in column b of table 1
I would like to avoid delimiting the values in the shared cells of table 2.
Thanks in advance for your help!
If your reference number are unique, you can get by with doing a wildcard vlookup
Assume you have a range in columns F and G where your reference numbers and months are. In Range A:B you want the values.
Essentially you are looking up like this.
If my value A1 is in column F and it matches a substring get the value from G
So you would use this formula in B1
=VLOOKUP(CONCATENATE("*", A1, "*"),$F$1:$G$6,2, FALSE)
what this is doing is, get the value from A1, and match the range of F:G where the first column CONTAINS A1, get the value from the corresponding G column
From there copy paste the formula for the rest of the
cells in B column

Calculate Average Time from Column B based on Values in Column A

I'm new to Excel. I'm looking for formula to perform the following.
Column B has values like TM, LA, Break etc. And Average Handling Time (AHT) will be captured in Column E. Now I need Average AHT for the values in Column B. Ex: If Column B has 6 "TM", then their respective time in Column E should be Averaged. This Avg value will be in Cell G4. Similarly I need Avg AHT time for other values in Column B. Can someone help me in this..
Please Refer to the attached Image above
AVERAGEIF
Use the AVERAGEIF function.
Place the following formula in G4 and copy to the right:
=AVERAGEIF($B$4:$B$15,RIGHT(G$3,2),$E$4:$E$15)
Format G4 and H4 to the desired time format or you will see a decimal number.
Proof of Concept
Explanation:
The AVERAGEIF function has three arguments
=AVERAGEIF(A, B, C)
A: Range of cells that has you criteria in it
B: What your criteria is
C: Range of cells to take the corresponding average of
In this case A is $B$4:$B$15. The cell addresses have been lock with the $ to prevent them from changing when the formula is copied.
For B we used the RIGHT(G$3,2) formula. This pulled the last two characters from your header above. Only rows in B that match the last two characters of the headers will be used for the average calculation. Alternatively, this could have been hard coded as "TM" or "LA"
For C, the times in the range $E$4:$E$15 were supplied. The values that match were added together and then that sum was divided by the number of matches to get the average.

Resources