Excel vlookup get the highest value - excel

Here is the excel function:
start date =IF(A6 = 1, C3, VLOOKUP(A6 -1, $A$6:$D$13, 4, FALSE))
end date =C6+B6
I intend to get the latest end date value if there is multiple rows on previous sequences, for example as below:
On the yellow cell, it should get the 23/2/2019 instead of 18/2/2019.

Use LOOKUP:
=IF(A12=1,C9,LOOKUP(A12-1,$A$6:$A$13,$D$6:$D$13))
Edit:
to get latest date you can use AGGREGATE function:
=IF(A6 = 1; C3; AGGREGATE(14;4;($A$6:$A$13=A6 -1)*$D$6:$D$13;1))

I think this will serve your purpose. This is formula for first start-date value and drag it downwards.
=IF(A6=1,$C$3,MAX(IF(A6-1=$A$6:$A$14,VLOOKUP(A6-1,$A$6:$D$14,3)+$B$6:$B$14)))
NOTE this is array formula so enter it with ctrl + shift + enter and check for curly braces around the formula. The screenshot to check for all conditions
Check for seq 6, I added two values sorted differently now

Related

Microsoft Excel - Grabbing values > 0

Is there any way using Microsoft excel to do an equation that does something like this:
IF(Condition, If true, If false) <-- Just in case, this is how an if statement is formatted
IF(a cell in a range has a value other than zero, put that/those value(s) here, do nothing)
For example:
IF(B1:B13 is something other than 0, grab that value, do nothing)
Based on the table above and the "equation" I am trying to figure out, it would return 12 and 17, 15.
Let me know if I need to clarify anything.
If one has the Dynamic Array formula FILTER():
=FILTER(B2:B100,B2:B100<>0)
If not then put this in the first cell and copy down:
=IFERROR(INDEX(B:B,AGGREGATE(15,7,ROW($B$2:$B$100)/($B$2:$B$100<>0),ROW($ZZ1))),"")
If your version of Excel supportsTEXTJOIN(),use:
=TEXTJOIN(",",TRUE,IF(B1:B13=0,"",B1:B13))
EDIT#1:
Some versions of Excel may require this formula to be array-entered.Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

Is excel how to get the max number with condition?

In Excel, I use the Col A as the id number for my data, and the ID number begin at the year. Such as 2018xxxxxxx. I want to get the Max id number for a year.
In python, use a simple condition check, then I can get the result. Such as.
col_A_max = max([x for x in range(A) if str(x) == '2016'])
I try to rewrite it in Excel but it did not work.
=max(if(A:A, left(A:A, 4) = "2016", A:A))
Try this array formula:
=max(if(left(A:A, 4) = "2016", A:A))
Use Ctrl, Shift and Enter to confirm. (The first 6 characters will never be "2018".)
This might depend on whether you are using dates.
MAX Array Formula
The following are array formulas. After they are entered (copied) to the formula bar, hold LEFT CONTROL + SHIFT and press ENTER. (Enter them without the curly braces ({})).
{=MAX((LEFT(A:A,4)="2016")*A:A)}
{=MAX((LEFT(A$1:A$20,4)="2016")*A$1:A$20)}
The following image demonstrates how this formula will work if the values in the A column are either numbers or numbers formatted as text, while the other formulas will not. This principle cannot be applied to MIN.

Formula to find the second to last value in row - Excel

I have the formula to find the last value in a row - =LOOKUP(1,1/(3:3>0),3:3) (depending on the row)
but can't seem to get it to return the second to last value/cell in the row.
Please help!
Try,
=INDEX(3:3, AGGREGATE(14, 6, COLUMN(A:XFC)/(A3:XFC3>0), 2))
Awesome.. I edited the formula to:
=INDEX(3:3, AGGREGATE(14, 6, COLUMN(A3:XFC3)/(A3:BL3>0), 2))
Where BL3 is where my current last data value ends. Once I drag, the formula automatically updated the column and row value.
Thanks so much!
For row #3, the array formula:
=INDEX(3:3,IF(COUNTA(3:3)=0,"",MAX((3:3<>"")*(COLUMN(3:3))))-1)
will yield the next-to-last value in that row:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
If you are sure that row #3 will not be empty, then use this array formula instead:
=INDEX(3:3,MAX((3:3<>"")*(COLUMN(3:3)))-1)
To avoid array formulas consider:
=INDEX(3:3,SUMPRODUCT(MAX((COLUMN(3:3))*(3:3<>"")))-1)

COUNTIFS formula to count unique records where range contains dates within specified year criteria

I've been Googling for hours trying to create a COUNTIFS formula that will:
count the unique records in a table range
that have dates that fall within 4 years after
a year in a referenced cell
This is what I have so far: =COUNTIFS(dte_degr_conferred2,"<="&YEAR('Student Success and Progress'!$G$1)+4) but it is not correct and I've tried several variations
Please note: dte_degr_conferred2 column contains dates, 'Student Success and Progress'!$G$1 contains a 4-digit year
Many Thanks
Perhaps you mean this array formula**:
=SUM(IF(FREQUENCY(IF(dte_degr_conferred2<>"",IF(YEAR(dte_degr_conferred2)='Student Success and Progress'!G1,dte_degr_conferred2)),dte_degr_conferred2),1))
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Trying to work out exactly what you need (you might be overcomplicating). Here is an example of using the COUNTIFS formula to compare dates. This formula was entered into cell E6 with the setup as below:
=COUNTIFS($B$2:$B$6,"<="&E3+4,$B$2:$B$6,">="&E3)
I have an even more simplistic interpretation:
=COUNTIF(dte_degr_conferred2,">="&DATE('Student Success and Progress'!$G$1+4,1,1))
The "count unique" requirement makes this an interesting question.
Here's what I've come up with:
=SUM(
IF(
FREQUENCY(
IF((YEAR(ddc)>=ssp!$G$1) + (YEAR(ddc)<ssp!$G$1+4) = 2, ddc, ""),
IF((YEAR(ddc)>=ssp!$G$1) + (YEAR(ddc)<ssp!$G$1+4) = 2, ddc, "")
)>0,
1
)
)
... where ddc is dte_degr_conferred2 and ssp is 'Student Success and Progress'. (When posting to SO, it's helpful to reduce a question to its essentials, because that makes it easier to respond to, as well as making it more universally useful.)
Enter as an array formula: Ctrl + Shift + Enter
Example
In this example, there are three distinct dates that match the criteria: 05/12/2014, 09/12/2014, and 05/26/2012.
How it works:
When creating array formulas, it can be useful to work out the calculations separately before joining them in an array. I've done so here:
Column C is =(YEAR(A1)>=$B$1) + (YEAR(A1)<$B$1+4) (copied down). In Excel, TRUE is 1 and FALSE is 0, so you can add boolean values together. If A1 is between B1 and B1+4, both operands are TRUE, and TRUE + TRUE = 2.
Column D is =IF(C1=2,A1,"") (copied down). This grabs the data that matches the criteria. (I formatted as numbers to highlight the fact that Excel stores dates as numbers.)
Column E is =SUM(IF(FREQUENCY(D1:D10,D1:D10)>0,1)). For an explanation of this method, see http://office.microsoft.com/en-us/excel-help/count-occurrences-of-values-or-unique-values-in-a-data-range-HP003056118.aspx
My solution at top combines all this into a single array formula.

How to use "find" to add a condition in "sumproduction" in Excel forrmual

I have two columns, one "floor", floor can be written as an integer or a string "4-5" means 2 floors between 4F and 5F, then another is price, I need to "SUMPRODUCT" all the price for all floors.
I do not want to use hidden columns to help the calcuate, only one formula in the totle price cell.
have tried find,search,match,vlookup for this but get error #VALUE
this the formula I written in "find".
=SUMPRODUCT(K45:K59,(NOT(ISERROR(INT(H45:H59))))*1)+IF(AND(NOT(ISERROR(FIND("-",H45:H59))),NOT(ISERROR(INT(MID(H45:H59,1,FIND("-",H45:H59)-1)))),NOT(ISERROR(INT(MID(H45:H59,FIND("-",H45:H59)+1,LEN(H45:H59)))))),INT(MID(H45:H59,FIND("-",H45:H59)+1,LEN(H45:H59)))-INT(MID(H45:H59,1,FIND("-",H45:H59)-1))+1,0)
You can use SUMPRODUCT for this:
=SUMPRODUCT(
IF(ISNUMBER(H$45:H$59),
1,
MID(H$45:H$59,FIND("-",H$45:H$59)+1,10)-MID(H$45:H$59,1,FIND("-",H$45:H$59)-1)+1
),
I$45:I$59
)
Enter it as an array formula: Ctrl + Shift + Enter.
Output
I finally gave up the attempt of writing a single smart formula. because the row count of block is fixed, I divide the formula into a long-but-similar formula.
=(IF(AND(NOT(ISERROR(FIND("-",H45))),NOT(ISERROR(INT(MID(H45,1,FIND("-",H45)-1)))),NOT(ISERROR(INT(MID(H45,FIND("-",H45)+1,LEN(H45)))))),(INT(MID(H45,FIND("-",H45)+1,LEN(H45)))-INT(MID(H45,1,FIND("-",H45)-1))+1)*K45,K45))+(IF(AND(NOT(ISERROR(FIND("-",H46))),NOT(ISERROR(INT(MID(H46,1,FIND("-",H46)-1)))),NOT(ISERROR(INT(MID(H46,FIND("-",H46)+1,LEN(H46)))))),(INT(MID(H46,FIND("-",H46)+1,LEN(H46)))-INT(MID(H46,1,FIND("-",H46)-1))+1)*K46,K46))+(IF(AND(NOT(ISERROR(FIND("-",H47))),NOT(ISERROR(INT(MID(H47,1,FIND("-",H47)-1)))),NOT(ISERROR(INT(MID(H47,FIND("-",H47)+1,LEN(H47)))))),(INT(MID(H47,FIND("-",H47)+1,LEN(H47)))-INT(MID(H47,1,FIND("-",H47)-1))+1)*K47,K47))+(IF(AND(NOT(ISERROR(FIND("-",H48))),NOT(ISERROR(INT(MID(H48,1,FIND("-",H48)-1)))),NOT(ISERROR(INT(MID(H48,FIND("-",H48)+1,LEN(H48)))))),(INT(MID(H48,FIND("-",H48)+1,LEN(H48)))-INT(MID(H48,1,FIND("-",H48)-1))+1)*K48,K48))+(IF(AND(NOT(ISERROR(FIND("-",H49))),NOT(ISERROR(INT(MID(H49,1,FIND("-",H49)-1)))),NOT(ISERROR(INT(MID(H49,FIND("-",H49)+1,LEN(H49)))))),(INT(MID(H49,FIND("-",H49)+1,LEN(H49)))-INT(MID(H49,1,FIND("-",H49)-1))+1)*K49,K49))+(IF(AND(NOT(ISERROR(FIND("-",H50))),NOT(ISERROR(INT(MID(H50,1,FIND("-",H50)-1)))),NOT(ISERROR(INT(MID(H50,FIND("-",H50)+1,LEN(H50)))))),(INT(MID(H50,FIND("-",H50)+1,LEN(H50)))-INT(MID(H50,1,FIND("-",H50)-1))+1)*K50,K50))+(IF(AND(NOT(ISERROR(FIND("-",H51))),NOT(ISERROR(INT(MID(H51,1,FIND("-",H51)-1)))),NOT(ISERROR(INT(MID(H51,FIND("-",H51)+1,LEN(H51)))))),(INT(MID(H51,FIND("-",H51)+1,LEN(H51)))-INT(MID(H51,1,FIND("-",H51)-1))+1)*K51,K51))+(IF(AND(NOT(ISERROR(FIND("-",H52))),NOT(ISERROR(INT(MID(H52,1,FIND("-",H52)-1)))),NOT(ISERROR(INT(MID(H52,FIND("-",H52)+1,LEN(H52)))))),(INT(MID(H52,FIND("-",H52)+1,LEN(H52)))-INT(MID(H52,1,FIND("-",H52)-1))+1)*K52,K52))+(IF(AND(NOT(ISERROR(FIND("-",H53))),NOT(ISERROR(INT(MID(H53,1,FIND("-",H53)-1)))),NOT(ISERROR(INT(MID(H53,FIND("-",H53)+1,LEN(H53)))))),(INT(MID(H53,FIND("-",H53)+1,LEN(H53)))-INT(MID(H53,1,FIND("-",H53)-1))+1)*K53,K53))+(IF(AND(NOT(ISERROR(FIND("-",H54))),NOT(ISERROR(INT(MID(H54,1,FIND("-",H54)-1)))),NOT(ISERROR(INT(MID(H54,FIND("-",H54)+1,LEN(H54)))))),(INT(MID(H54,FIND("-",H54)+1,LEN(H54)))-INT(MID(H54,1,FIND("-",H54)-1))+1)*K54,K54))+(IF(AND(NOT(ISERROR(FIND("-",H55))),NOT(ISERROR(INT(MID(H55,1,FIND("-",H55)-1)))),NOT(ISERROR(INT(MID(H55,FIND("-",H55)+1,LEN(H55)))))),(INT(MID(H55,FIND("-",H55)+1,LEN(H55)))-INT(MID(H55,1,FIND("-",H55)-1))+1)*K55,K55))+(IF(AND(NOT(ISERROR(FIND("-",H56))),NOT(ISERROR(INT(MID(H56,1,FIND("-",H56)-1)))),NOT(ISERROR(INT(MID(H56,FIND("-",H56)+1,LEN(H56)))))),(INT(MID(H56,FIND("-",H56)+1,LEN(H56)))-INT(MID(H56,1,FIND("-",H56)-1))+1)*K56,K56))+(IF(AND(NOT(ISERROR(FIND("-",H57))),NOT(ISERROR(INT(MID(H57,1,FIND("-",H57)-1)))),NOT(ISERROR(INT(MID(H57,FIND("-",H57)+1,LEN(H57)))))),(INT(MID(H57,FIND("-",H57)+1,LEN(H57)))-INT(MID(H57,1,FIND("-",H57)-1))+1)*K57,K57))+(IF(AND(NOT(ISERROR(FIND("-",H58))),NOT(ISERROR(INT(MID(H58,1,FIND("-",H58)-1)))),NOT(ISERROR(INT(MID(H58,FIND("-",H58)+1,LEN(H58)))))),(INT(MID(H58,FIND("-",H58)+1,LEN(H58)))-INT(MID(H58,1,FIND("-",H58)-1))+1)*K58,K58))+(IF(AND(NOT(ISERROR(FIND("-",H59))),NOT(ISERROR(INT(MID(H59,1,FIND("-",H59)-1)))),NOT(ISERROR(INT(MID(H59,FIND("-",H59)+1,LEN(H59)))))),(INT(MID(H59,FIND("-",H59)+1,LEN(H59)))-INT(MID(H59,1,FIND("-",H59)-1))+1)*K59,K59))

Resources