I want to find which user is "P" given a date in data below.
I've tried retrieving the row number of the given date using "=MATCH(A5,$A$4:$A$5,0)"
and also the column number of "P", using "=MATCH("P",B5:G5,0)"
I'm unsure how to bring them together to get the desired output.
Thanks for any help.
Nested INDEX/MATCH
=IFNA(INDEX($B$1:$G$1,1,MATCH($J2,INDEX($B$2:$G$3,MATCH($I2,$A$2:$A$3,0),0),0)),"")
Insert a new column H where H4 has a formula of =INDEX(B$3:G$3,MATCH("P",B4:G4,0).
Then your second table's second column formula can be =INDEX(H$4:H$5, MATCH(yourDateCellHere, A$4:A$5,0)) because a lot of the heavy lifting is already done in the first table.
Then, if you wish, hide your new column H.
Related
I wish to construct 2 current status columns so as find the last values in each row in Excel:
one for the last Date and the other for the last person who needs to act.
Please see the attached jpg To return the last values in a row for Date and Person to Act
I have tried to use the excel functions, namely, INDEX or LOOKUP but to no avail because of the 3 Remarks columns within the table.
I would appreciate it if you could advise me how to craft a VBA code to the above query.
From LC TAN 2020-02-13
You're on the right track.
you can use LOOKUP to return the last element in an array
BUT you have to ensure your array only has the elements that you want to consider
There is a variation of the INDEX function where you can enter an array for the column (or row) argument and return selected items. You enter the array, or arra constant, in a format like:
N(IF(1,*array or arrayConstant*))
So, a formula that would work for your requirements would be:
L6: =LOOKUP(2,1/LEN(INDEX($B6:$J6,N(IF(1,{2,5,8})))),INDEX($B6:$J6,N(IF(1,{2,5,8}))))
and fill down.
You can use MAX for the date to find the latest date in that row.
You can then use IFERROR and VLOOKUP to find the action with that date. i.e. lookup the date that MAX has returned in the first set of columns, and if that returns an error, look in the second. If the second returns an error, look in the third.
As per your sheet, the formula for L6 would be =MAX(B5:I5)
The formula for M6 would be =IFERROR(VLOOKUP(L5,B5:C5,2,FALSE),IFERROR(VLOOKUP(L5,E5:F5,2,FALSE),VLOOKUP(L5,H5:I5,2,FALSE)))
You can then drag the cells down to populate the date and action for every row. You could achieve the same with VBA if you wanted to, but I would have thought that this is the easiest way to get the the desired result.
I have a table in which multiple weeks of data is stored and I'm trying to return a value based on 2 criteria.
Column A of the data sheet contains the date the report was ran (Always on the same day of the week - 24/05/17, 31/05/17 etc)
I've managed to return the value of column H by using an array formula, based on a cell value (Date) in ''Issues Data Quality Overview'!$B$4' using the following formula:
{=IFERROR(INDEX('Issues Log'!$H$1:$H$20000,SMALL(IF('Issues Data Quality Overview'!$B$4='Issues Log'!$A$1:$A$20000,ROW('Issues Log'!$A$1:$A$20000)-MIN(ROW('Issues Log'!$A$1:$A$20000))+1,""), ROW(A2))),"")}
That returns a value such as "IID-10225-22".
Problem:
Now I need to look up that value in the same table, based on a date in another cell, and return column X. (essentially adding the returned value as a criteria).
In all honesty I'm lost as to how I'd do this.
#Matthew. I understand your formula gives the list of values in column H with column A values matching 'Issues Data Quality Overview'!$B$4 in an ordered list.
Does your Issues Log, column H have multiple occurrence of the same value? (example: IID-10255-22 can have a value in Issues Log, column A that is not the same value as 'Issues Data Quality Overview'!$B$4).
If not, it doesn't make sense to use the result as a lookup value to get column X, you can simply change the code to:
{=IFERROR(INDEX('Issues Log'!$X$1:$X$20000,...}
If it does have multiple occurrences and you want to get the first occurrence of the result in column H and get the value in column X, best to add a formula right next to your array formula and do a VLOOKUP.
I've scrapped the array formula, as it really slowed down the processing speed. Instead I've created a Unique ID (=IssueID&Date) and VLookup'd that.
Please pardon my poor explanation of my problem, any insight would be greatly appreciated.
I am using an average in excel that begins at a fixed cell and fills down.
For example: column B contains values, and column C contains the formula =AVERAGE($B$1:B1) filled down, so at row 10 the formula is =AVERAGE($B$1:B10)
I am wondering if there is a way to calculate this average that will "reset" when the value in the column A changes. Getting a formula for whether column A changes is easy using an IF function but I don't know how to change the reference cell when the average "resets." I attempted to attach an image with the formulas but I do not have 10 reputation so here is a link to a short example sheet:
https://drive.google.com/file/d/0BymZUcneHsYgUnRoYkRkdnJYbmM/view?usp=sharing
I would prefer do accomplish this without VBA if possible.
Thank you very much.
EDIT: would it be possible to have a count function next to the data column that starts over when column A switches from "A" to "B" (or "B" to "A"), then I could simply use an average offset with the resulting value to get the desired average?
You should use the =AVERAGEIF function.
=AVERAGEIF($A$1:A1,A1,$B$1:B1)
Here's how I ended up solving this:
I used =ROW()-MAX(INDEX((A$1:A2<>A2)*ROW(A$1:A2),0 to count down until "A" changed to "B" or vice versa, then used =ROW()-MAX(INDEX((A$1:A2<>A2)*ROW(A$1:A2),0 to average the data with the offset calculated in the previous formula.
Note that the data was still in column B, with "A" or "B" in column A, and these two formulas were placed in I and J, respectively
Thank you very much for all your help
You can use Indirect to resolve a custom range. Since values in "A" can come multiple time in distinct block, you will have to add an extra column to keep track of the starting row of each range :
(starting from row 2, [C1] = 1)
=IF(A2<>A1,ROW(A2),C1)
the result will be in column "D" :
=AVERAGE(INDIRECT("B"& C1 &":B"&ROW(A1)))
I have a question regarding the RANK function in MS Excel 2010. I have a large worksheet whose rows I want to rank based on the values in a column. These values can be positive or negative. I found helpful advice here which explains how to rank the values in a column while excluding all values that equal zero from the ranking and the ranking count. They use the following formula:
IF(O24<0, RANK(O24,$O$24:$O$29) - COUNTIF($O$24:$O$29,0), IF(O24=0, "", RANK(O24,$O$24:$O$29)))
This works great, but it would be even better if I could rank the values only if a corresponding value in the same row but a different column meets certain criteria.
Is something like this possible and how would I do it? How would I update the example formula above to make the change work? Thank you very much in advance for your help.
P.S.: I tried putting in a table but it didn't really work, sorry...
You can use COUNTIFS function to rank based on a condition in another column, e.g. this formula in row 24 copied down [edited to include extra IF)
=IF(O24=0,"",IF(N24="x",COUNTIFS(O$24:O$29,">"&O24,O$24:O$29,"<>0",N$24:N$29,"x")+1,""))
That will rank high to low where column N = "x", ignoring zero values
See this example columns N and O contain random values - press F9 to re-generate new random values and formula results in column Q will change accordingly
It is certainly possible to keep creating more complex formulas whenever you're adding new criteria on which to rank. However by creating intermediary columns with single-step formulas, you'll make your spreadsheet easier to comprehend and easier to add new criteria or edit the existing.
My suggestion is to create a column that excludes the zero's (let's assume this is in column P): =IF(O24 = 0, "", O24)
Then in column R, to eliminate negative values (this step is unnecessary, but your original formula does something similar): =IF(P24 = "", "", P24 - MIN(0, MIN($O$24:$O$29)))
Now in column S, add your newest criteria: =IF(OR(R24="", [enter newest criteria here]), "", R24)
Finally, column T performs the ranking of only the selected rows: =IF(S24="", "", RANK(S24, S$24:S$29))
If exposing columns P, R and S is bothersome, you can always hide them.
A rewording of the answer from barry houdini, using table format.
Value_Col is the column with the values to rank. Group_Column is the column with the group by values, to rank within groups
=COUNTIFS([Value_Col], ">"&[#[Value]], [Value_Column],"<>0", [Group_Column], [#[Group]]) +1
Basically my problem is that I have a string in one cell in excel, I then need to see if that string exists in another row (not one cell but the whole row) and if so then print the contents of another cell in the same row but in another column.
I will give a basic example:
Title Answer
Police 15
Ambulance 20
Fire 89
Now I need to scan the title column for, say, "Police" and then populate the cell with the value under Answer (in this case 15).
I cant just say IF(A2="Police";B2;"" as I need the scan the whole of the Title column.
I have tried using IF(COUNTIF(A$2:A$100;"Police"); which scans the contents of A2 to A100 for the string Police, and know how to make it print a constant (just put something after the ;) but cant work out how to make that "constant" a variable that changes depending on the found row. So if the COUNTIF found Police in cell A44 then the answer to my formula would be B44, the same as if it found Police in A62 then my formula should show B62
I hope this makes sense and that someone can help me :)
Note that I am using excel 2010 and need a normal formula as I can not use scripting for this document.
EDIT:
Here is what I have so far, note that the spreadsheet I am using is far more complex than the "simple" example I have in the question...
=IF(ISNUMBER(FIND("RuhrP";F9));LOOKUP(A9;Ruhrpumpen!A$5:A$100;Ruhrpumpen!I$5:I$100);"")
This is showing "RuhrP" in every answer where "RuhrP" is found in F9 and not the answer I want which should be that found in RuhrPumpen!I$5:I$100 where the cell index is the same as that for the A coloum where A9 was found. Again, sorry for the complexity I cant think of any better way to word it.
I note you suggested this formula
=IF(ISNUMBER(FIND("RuhrP";F9));LOOKUP(A9;Ruhrpumpen!A$5:A$100;Ruhrpumpen!I$5:I$100);"")
.....but LOOKUP isn't appropriate here because I assume you want an exact match (LOOKUP won't guarantee that and also data in lookup range has to be sorted), so VLOOKUP or INDEX/MATCH would be better....and you can also use IFERROR to avoid the IF function, i.e
=IFERROR(VLOOKUP(A9;Ruhrpumpen!A$5:Z$100;9;0);"")
Note: VLOOKUP always looks up the lookup value (A9) in the first column of the "table array" and returns a value from the nth column of the "table array" where n is defined by col_index_num, in this case 9
INDEX/MATCH is sometimes more flexible because you can explicitly define the lookup column and the return column (and return column can be to the left of the lookup column which can't be the case in VLOOKUP), so that would look like this:
=IFERROR(INDEX(Ruhrpumpen!I$5:I$100;MATCH(A9;Ruhrpumpen!A$5:A$100;0));"")
INDEX/MATCH also allows you to more easily return multiple values from different columns, e.g. by using $ signs in front of A9 and the lookup range Ruhrpumpen!A$5:A$100, i.e.
=IFERROR(INDEX(Ruhrpumpen!I$5:I$100;MATCH($A9;Ruhrpumpen!$A$5:$A$100;0));"")
this version can be dragged across to get successive values from column I, column J, column K etc.....
Assuming
source data range is A1:B100.
query cell is D1 (here you will input Police or Fire).
result cell is E1
Formula in E1 = VLOOKUP(D1, A1:B100, 2, FALSE)
I figured out such data design:
Main sheet:
Column A: Pump codes (numbers)
Column B: formula showing a corresponding row in sheet 'Ruhrpumpen'
=ROW(Pump_codes)+MATCH(A2;Ruhrpumpen!$I$5:$I$100;0)
Formulae have ";" instead of ",", it should be also German notation. If not, pleace replace.
Column C: formula showing data in 'Ruhrpumpen' column A from a row found by formula in col B
=INDIRECT("Ruhrpumpen!A"&$B2)
Column D: formula showing data in 'Ruhrpumpen' column B from a row found by formula in col B:
=INDIRECT("Ruhrpumpen!B"&$B2)
Sheet 'Ruhrpumpen':
Column A: some data about a certain pump
Column B: some more data
Column I: pump codes. Beginning of the list includes defined name 'Pump_codes' used by the formula in column B of the main sheet.
Spreadsheet example: http://www.bumpclub.ee/~jyri_r/Excel/Data_from_other_sheet_by_code_row.xls
Guys Its very interesting to know that many of us face the problem of replication of lookup value while using the Vlookup/Index with Match or Hlookup.... If we have duplicate value in a cell we all know, Vlookup will pick up against the first item would be matching in loopkup array....So here is solution for you all...
e.g.
in Column A we have field called company....
Column A Column B Column C
Company_Name Value
Monster 25000
Naukri 30000
WNS 80000
American Express 40000
Bank of America 50000
Alcatel Lucent 35000
Google 75000
Microsoft 60000
Monster 35000
Bank of America 15000
Now if you lookup the above dataset, you would see the duplicity is in Company Name at Row No# 10 & 11. So if you put the vlookup, the data will be picking up which comes first..But if you use the below formula, you can make your lookup value Unique and can pick any data easily without having any dispute or facing any problem
Put the formula in C2.........A2&"_"&COUNTIF(A2:$A$2,A2)..........Result will be Monster_1 for first line item and for row no 10 & 11.....Monster_2, Bank of America_2 respectively....Here you go now you have the unique value so now you can pick any data easily now..
Cheers!!!
Anil Dhawan