Multiple VLOOKUPs and a max value - excel

I have a calendar year in Column A and am looking to find a match in column CA. There are multiple matches and within these I am then looking for the match that has "A" in the row next to it. there could be duplicates of this as well and so of those will copy the max value (In column CK). At the moment I have tried some looped vlookup() excel functions but have had no luck. Any help would be appreciated, thanks!
=VLOOKUP(A2&"A", $CA:$CK, 11, FALSE)

Use INDEX/MATCH instead of VLOOKUP().
=INDEX(CK:CK,MATCH(A2&"A",CA:CA&CB:CB,0))
In case of non 365 version of excel, you may need to array entry the formula with CTRL+SHIFT+ENTER.

Related

Excel - How to count the number of distinct texts of a specific date inside a table?

I'm trying to count the number of distinct text from a specific date in a data table.
Data Sample with expect result :
I was able to figure out how to count the distinct element from a range I specify, because I can determine the first and last row containing the date.
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
I have tried to modify my formula so that it determines the cell range by itself but without success.
I searched for an answer, using a combination of CELL and MAXIFS, example below, but Excel does not accept the formula.
=CELL("row",MAXIFS(A2:A15,A2:a15,D2))
I've looked at the INDEX formula, but I can't figure out how to do what I want to do. 😑
Any idea what I'm doing wrong, or what I should be doing instead?
Thanks, I appreciate it!
If you have Office 365 and the new Dynamic Arrays, this sort of formula has become ridiculously easy.
This formula in cell E3:
=COUNTA(UNIQUE(FILTER($B$2:$B$15,$A$2:$A$15=D3)))
Copy down.
You can also generate the unique list of dates with this formula in D3, which spills down automatically and does not need to be copied.
=UNIQUE(A2:A15)
It wasn't easy, but by separating each step of the problem, I was able to solve it.
Note that my solution only works because my dates are sorted.
Here's the final formula in the cell "One formula to rule them all":
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2))),INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)))))
Here are my explanations of my process:
Formula if I select the range :
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
Formula to get the first iteration
=ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2)
Formula to get the last iteration
{=ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)}
Create range from two addresses
=INDIRECT(CONCATENATE(F3,":",G3))
Formula giving me the expect result
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(F3,":",G3)),INDIRECT(CONCATENATE(F3,":",G3))))

Index Match formula issue with multiple criteria

I have an issue with Index/match formula in Excel.
I have the following formula;
INDEX('[Master 2019-20.xlsx]SM'!$G$2:$G$5000,MATCH(1,('[Master 2019-20.xlsx]SM'!$M$2:$M$5000=$C2)*('[Master 2019-20.xlsx]SM'!C$2:$C$5000=$B2)*('[Master 2019-20.xlsx]SM'!$AE$2:$AE$5000=$A2),0))
Detail around the formula..
Index is column 'G' which is a list of reference numbers.
first match is from column 'M' which is a product description.
second match is from column 'C' which is the week number.
third match is a count column 'AE' which is looking for '1'.
This returns the value I require for that week if there is only one entry for that given week. the problem comes if there is more than one entry for that week? how can I show all reference's within a single week that meets the above criteria?
is there a way of populating a list that if the above criteria is met then it will show all associated references from column 'G'.
Any help with this would be appreciated. any other formula suggestions also welcome.
Thanks in advance.
Hereby a small example:
Formula in F2:
=IFERROR(INDEX(A$1:A$11,SMALL(IF((B$2:B$11="A")*(C$2:C$11<10),ROW(A$2:A$11)),ROW(1:1))),"")
So here I looked for values with the following criteria:
Value = A under header2
Value is less than 10 under header 3
Note1: It's an array formula and need to be confirmed through CtrlShiftEnter
Note2: If I made no copy paste errors, that would mean you need to use: =IFERROR(INDEX('[Master 2019-20.xlsx]SM'!G$1:G$5000,SMALL(IF(('[Master 2019-20.xlsx]SM'!$M$2:$M$5000=C$2)*('[Master 2019-20.xlsx]SM'!C$2:$C$5000=B$2)*('[Master 2019-20.xlsx]SM'!AE$2:AE$5000=A$2),ROW('[Master 2019-20.xlsx]SM'!G$2:G$5000)),ROW(1:1))),"")

Excel Countifs or SumProduct formulas

I have collision data in column F I have the years from 2004-2015, I have named the range ATT_YEAR and In column G I have the dates and the range is named ATT_DATE. What I am trying to do is to either use COUNTIFS or SUMPRODUCT to determine the number of collisions by month of the year, if I select the year as say 2013, I want to show the number of collisions by month.
I was trying the following the formula:
=COUNTIFS(ATT_YEAR,"2013",ATT_DATE,MONTH=1)
but not getting very far with one.
Or when I tried using sumproduct formula:
=SUMPRODUCT(--(ATT_YEAR,"2013"),MONTH(ATT_DATE)=1)
I would be grateful for any assist on either of these.
I think you are using the formula wrong:
=SUMIFS(COLLISION,ATT_YEAR,2013,ATT_MONTH,1)
This will count all collisions in the named-range "COLLISION" only if 2013 is matched in the named-range "ATT_YEAR" and 1 (i.e. January) is matched in the named-range "ATT_MONTH".
edit
Needs updating, wrong assumptions.
You cannot use MONTH, which is the function you need, inside COUNTIFS. Instead, create another column, with the formula MONTH(B2), assuming column B has the date values, and use it as a new ATT_MONTH range:
=COUNTIFS(ATT_YEAR,2004,ATT_MONTH,6)

Excel dynamic column value based on other columns

I have an Excel spreadsheet where the A column is a list of email address and columns C-P represent VLOOKUP formulas to return a phone number. Each column represents a different source.
C-P columns will only contain one value and the rest will be #N/A. How do I fill the B column with the valid value from the C-P columns, assuming there is one?
I tried to do a formula using nested IFNAs but it seems to be the case that Excel only allows up to 8 nested if statements, and there are more than 8 columns in my spreadsheet so that is not a valid solution for my problem.
I believe this should be possible using formulas alone so I was hoping to find a solution that accomplishes that. Does anyone have any ideas on how I may be able to approach this problem?
Like the SUMPRODUCT function, the newer AGGREGATE function can provide cyclic processing with some of its sub-functions but also discard errors.
=IFERROR(INDEX(C2:P2, AGGREGATE(15, 6, COLUMN(A:O)/SIGN(LEN(C2:P2)), 1)), "")
I've added an IFERROR function wrappe to avoid another #N/A in case 'assuming there is one' is not correct.

Excel Countif with multiple if requirements

I have an Excel document that has a date column (A) and a column containing strings (B) one one sheet. On another sheet, I am doing calculations. If the cell in column A is between DATE(2012,1,1) and DATE(2012,6,1) AND the same row in column B contains "string" in any part (string) then it should count that row. Google mentioned using SUMPRODUCT but I was only able to get date between to work. Below is the SUMPRODUCT for date between.
=SUMPRODUCT(--('Sheet1'!A:A>=DATE(2012,1,1)),--('Sheet1'!A:A>=DATE(2012,6,1)))
I tried using this for the final value but it is incorrect.
=SUMPRODUCT(--('Sheet1'!A:A>=DATE(2012,1,1)),--('Sheet1'!A:A>=DATE(2012,6,1)),--('Sheet1'!B:B="*"&"string"&"*"))
EDIT: Apparently the above works, but the string must be EQUAL to the value. * is not being recognized as a wildcard.
Thanks.
If you are using whole columns in SUMPRODUCT you must have Excel 2007 or later (otherwise that doesn't work), and you can use wildcards in COUNTIFS
=COUNTIFS('Sheet1'!A:A,">="&DATE(2012,1,1),'Sheet1'!A:A,"<="&DATE(2012,6,1),'Sheet1'!B:B,"*String*")
The issue you're running into is due to the fact that you can't use wildcards in that way in a SUMPRODUCT. A way that you can get around it (assuming you need to use SUMPRODUCT) is to use either SEARCH or FIND to create the necessary array for use in the SUMPRODUCT. Here is an example that has your target string in cell D1 (note that this needs to be entered as an array formula with Ctrl+Shift+Enter):
=SUMPRODUCT(
--(Sheet1!A:A>=DATE(2012,1,1)),
--(Sheet1!A:A<=DATE(2012,6,1)),
IFERROR(IF(SEARCH(D1,Sheet1!B:B)>0,1,0),0))
IFERROR accounts for the non-matches but is an Excel 2007 feature. If you're not using Excel 2007, you can try:
=SUMPRODUCT(
--(Sheet1!A:A>=DATE(2012,1,1)),
--(Sheet1!A:A<=DATE(2012,6,1)),
IF(ISERROR(IF(SEARCH(D1,Sheet1!B:B)>0,1,0)),0,IF(SEARCH(D1,Sheet1!B:B)>0,1,0)))
Also, in your example formula, you'll need switch the sign to <= in the comparison to June :)
Sumproduct does not allow for wildcards. You can search for strings using ISNUMBER(SEARCH("string",range)). The formula is below.
=SUMPRODUCT(--('Sheet1'!A:A>=DATE(2012,1,1)),--('Sheet1'!A:A<=DATE(2012,6,1)),--(ISNUMBER(SEARCH("string",'Sheet1'!B:B))))
What version of Excel are you using? If it is 2007 or later, you can use COUNTIFS; here is a link to the syntax. You may have to use two columns, even using COUNTIFS. On Sheet2, column A should check whether Sheet1, column B contains "string" using the following formula:
=IF(ISERR(FIND("string",'Sheet1'!B1)), FALSE, TRUE)
You will need to replace 'Sheet1'!B1 with whatever cell you need, then drag it down to make it have the same number of rows as your Sheet1, column B. Then you can use COUNTIFS:
=COUNTIFS('Sheet1'!A:A, ">=" DATE(2012,1,1), 'Sheet1'!A:A, ">=" & DATE(2012,6,1), A:A, TRUE.

Resources