Identify minimum and maximum values based on 3 criteria - excel

In the table shown, I need a formula for column D that will indicate the first date (minimum) and most recent date (maximum) that each participant (in column A) took survey A (in column C). Column D would need to indicate "first" and "last" tied to the Participant ID--for example, I would want D2 to populate with "3Last" and D5 to populate with "3First." Column E displays what I would need column D to display. If it's not a first or last date (something in between), or if it's not survey A, the cell in column D would be left blank or 0. If there is only one date that meets the criteria, it should return "First" rather than "Last." I'm pretty stumped on this one... Any help is much appreciated!

In E2, insert the ARRAY formula listed below. If you have never used an array formula, follow these steps:
select the formula from this page
copy it
go to excel
select cell E2,
press the 'F2' key
paste the formula
press CTRL+SHIFT+Enter (instead of just pressing enter)
To copy down, follow these steps:
Copy cell E2
Move down to cell E3 (instead of selecting a range)
Paste in cell E3
Select your range and paste from there.
If you don't copy down in this manner, it will tell you that you cannot change the array...
=IF($C2="A",IF($B2=MIN(IF(($C$2:$C$7=$C2)*($A$2:$A$7=$A2),$B$2:$B$7)),CONCATENATE($A2,"Last"),IF($B2=MAX(IF(($C$2:$C$7=$C2)*($A$2:$A$7=$A2),$B$2:$B$7)),CONCATENATE($A2,"First"))),0)
HTH

Related

Excel - Auto populate a cell based on exact adjacent value (when having same names)

I´m trying to get a cell to return the exact value adjacent to the item I´m searching for.
Here is an example of excel work
When introducing the second, or third ¨10¨, I want the H and G columns to show me the values next to the second or third ¨10¨, not the first values.
So. when introducing the second ¨10¨ I want column H to bring up Bonnie M and column G to bring up 55555.
Or the third ¨10¨ to bring up $B6 and $C6.
If you are open to a solution with a support/help column in your data table, you may try the following solution.
Assume:
Range A2:A10 is named list_Num
Range B2:B10 is named list_Name
Range C2:C10 is named list_Serial
I have added a new column called Index in column D. In cell D2, enter the following formula and drag it down to D10:
=A2&"-"&COUNTIF($A$2:A2,A2)
Then I named Range D2:D10 as list_Index.
Replace the dropdown list in column I with list_Index
Lastly, enter the following formula in Cell G2 and H2 irrespecitvely:
In cell G2 enter
=IFERROR(INDEX(list_Serial,MATCH(I2,list_index,0)),"")
In cell H2 enter
=IFERROR(INDEX(list_Name,MATCH(I2,list_index,0)),"")
Drag down the formula to apply across as shown below:
Let me know if you have any questions.

Excel Max Length of each column data

Simple one for someone hopefully. I'm trying to get the max length of each column in an excel sheet but it doesn't seem to be working now. I was using =MAX(LEN(A2:A200)) for example and because MAX is not an "official" formula but is still there you seem to have to press CTRL + ALT + SHIFT once you have finished typing it.
When I do this it puts curly brackets round the whole formula like this {=MAX(LEN(A2:A200))} but if I click into the cell they disappear. the length of the first column will appear but then if I autofill to the next column it shows same length of column data from the first column rather than calculating the next column.
Perhaps not a straight up programming question but scratching my head why this is not working now. I'm trying to show max length of each column above header column in new row.
Thanks
Andrew
In A1 enter the array formula:
=MAX(LEN(A2:A200))
then stop clicking.
Move to A1 with the ARROW keys. Touch Ctrl+c. Then paste to B2 through G2 using Ctrl+v:
This will put the array formula in the destination cells.
Use Gary's formula and instead of ENTER, do CTRL-SHIFT-ENTER
When I do this it puts curly brackets round the whole formula like this {=MAX(LEN(A2:A200))} but if I click into the cell they disappear. the length of the first column will appear but then if I autofill to the next column it shows same length of column data from the first column rather than calculating the next column.
It is right to use formulas with brackets (they are called Matrix formulas). The brackets disappears because when you edit the content of the cell you have to push Ctrl + Shift + Enter and not only Enter like normal formulas.
Let's assume all your data is in Sheet1 starting at cell A1.
Create Sheet2
Enter the =LEN(Sheet1!A1) formula in cell A1 on Sheet2
Pull Sheet2's A1 cell down/over to the right to cover the populated
range of Sheet1 (to copy the formula to every cell of the range in
scope) - this will give you the length of every cell in scope
Enter the =MAX(A1:A10) formula on Sheet2 in the first column below
the last line (A10 is assumed to be the last line of the first
column in this example - so the formula goes in A11)
Pull Sheet2's A11 cell over to the right till the last column to get
the MAX length of values for each column

Last Status By Date and Count

I want to extract the last status of a item by date from the sample data given below:
http://i.stack.imgur.com/T4I5W.png
I want the following result:
http://i.stack.imgur.com/xDF55.png
Can this be achieved using a formula or PivotTables?
With pivot table you can easily extract the max date of each item. But the status will be problematic.
So, the best way to do it, is not with a pivot table. but with 3 steps.
1) copy your item list to another sheet to the first column. (I will assume the your first sheet is Sheet1 and the 2nd is Sheet2) choose the entire column in the 2nd sheet and remove duplicates. (date ribbon -> remove duplicates)
2) find your max data for each item.
lets assume your first rows is header so in the 2nd rows on column b enter:
=max(if(Sheet1!b:b=b3,Sheet1!a:a,""))
Note that this an array formula so you have to enter this using ctrl+shift+enter
Now drag this formula to the end of rows
3) find the last status of each item
you have to do double lookup formula
on c2 enter:
=index(Sheet1!c:c,match(a2&b2,Sheet1!b:b&Sheet1!a:a,0),1)
Again, that this an array formula so you have to enter this using ctrl+shift+enter
And again, drag this formula to the end of rows.
Actually this can be done only with formulas and without copying the data in another worksheet.
Assuming your data is in the range A1:C16 (change as needed) then you can enter the following Array Formulas (press [Ctrl]+Shift]+[Enter] together):
Enter "Item" in E1 and this array formula in E2 then copy down till last record (E16 for this sample)
=IFERROR(INDEX($B$2:$B$16,MATCH(0,COUNTIF(E$1:E1,$B$2:$B$16),0)*1),"")
Enter "Date” in F1 and this array formula in F2 then copy down till last record (F16 for this sample)
=IF($E2="","",MAX(IF($B$2:$B$16=E2,$A$2:$A$16,"")))
Finally Enter “Status” in G1 and this array formula in G2 then copy down till last record (G16 for this sample)
=IF($E2="","",INDEX($C$2:$C$16,MATCH($E2&$F2,$B$2:$B$16&$A$2:$A$16,0),1))
Ranges within the formulas should be adjusted as needed, no need to point to all rows in the worksheet.

How to drag/copy Excel formulae to include cells at specified intervals

I have an Excel sheet in which I want start column D with the following formula:
=AVERAGE(C7:C10)
I want to be able to drag down column D to give the following formulae:
=AVERAGE(C11:C14)
=AVERAGE(C15:C18)
=AVERAGE(C19:C22)
etc.
However, if I just naively drag down, instead, I get:
=AVERAGE(C8:C11)
=AVERAGE(C9:C12)
=AVERAGE(C10:C13)
How can I change this behavior?
In column D enter
=AVERAGE(OFFSET($C$1,4*ROW(C1)+2,0,4))
Then when you drag it down column D, each successive cell will have the reference incremented by 4.
This answer assumes that the size of the ranges remain constant. If, for example, column G is unpopulated then G1=7;G2=11. Select both cells and pull the fill handle down as far as needed. The formula for D1 is=AVERAGE(INDIRECT("C"&G1&":C"&G1+3)), which can be filled down as far as needed.

Excel switch 2 cells around depending on value

I am new to excel and was wondering if you could help with an issue i am trying to figure out.
I have 3 columns and would like to switch A1 with B1 if the date dd/mm/yy in B1 is before the date in A1.
Okay, let's say that columns D and E are empty. You will put the formula in those columns. In column D will be the dates which should go to column A and in column E will be those to go in column B.
In cell D1, put the formula:
=IF(B1 < A1, B1, A1)
In cell E1, put the formula:
=IF(B1 < A1, A1, B1)
And copy the formula down.
Sidenote: To make things go a bit quicker, you can select both cells D1 and E1 (selecting D1 first), go to the bottom of the spreasheet using the scroll bar only push and hold Shift and click the cell E in the last row. This should select everything from above till that cell you clicked. Then release Shift and push Ctrl+D to replicate the formulae throughout the selected columns.
After having the all formulae, copy and paste as values in place (To paste as values, you right click and go to Paste Special, find 'Values' among the different options.
Copy again and paste onto columns A and B, then delete columns D and E.

Resources