Excel Formula - get the date of a maximal value within a list - excel

I have a rather big (long) table and need to do something quite simple but I'm currently with a sort of blackout...
Imagine that you have:
Date 1 Value 1 Date 2 Value 2 Date 3 Value 3 Date of MAX
... ... ... ... ... ... ????
I want to deploy in ???? a formula that will result in the date at which the maximal value (between Value 1...3) was registered. For instance:
Date 1 Value 1 Date 2 Value 2 Date 3 Value 3 Date of MAX
20160501 10 20160722 47 20161002 9 20160722
meaning, the Date of MAX is of Date 2 because that was the date at which the MAX was measured.
Thanks in advance.

You could do a more general solution using offset:-
=MAX(N(OFFSET(D2,0,COLUMN(A:D)*3)))
to find the largest value - put this in (say) R2.
Then find a match for it and pick out the corresponding date:-
=OFFSET(C2,0,MATCH(R2,N(OFFSET(D2,0,COLUMN(A:D)*3)),0)*3)
assuming the dates and values are every third column.
These are array formulae and must be entered with CtrlShiftEnter
If the last value really was in P21 you would have to give a row offset as well as a column offset.

OK, I found a dirty but simple solution (don't know why I didn't think of it at first):
=IF(G2>=MAX(G2,J2,M2,P21),F2,IF(J2>=MAX(G2,J2,M2,P21),I2,IF(M2>=MAX(G2,J2,M2,P21),L2,O2)))
where the pairs (4 of them) are at FG, IJ, LM, OP. Not elegant but does the job.

Related

Excel convert range of dates into time to find whether it is greater or less than timeframe

I have the below formula doing a count of what rows have a time greater than 3:00pm OR a time less than 4:00am. It works as expected if my rows E1:E5 are only times. However the issue is that column E is a date time and I would like to keep it that way. So the formula currently is returning 0.
Formula
=COUNTIF(E1:E5,">="&TIME(15,0,0)) + COUNTIF(E1:E5,"<="&TIME(4,0,0))
Column E
10/1/2018 2:40:58 AM
10/1/2018 2:11:58 AM
10/1/2018 2:09:50 AM
10/1/2018 9:41:53 AM
10/1/2018 9:22:21 AM
The formula should return the count of 3. Thanks for any help.!
If you're okay with a helper column (which you can hide all the way in the AA column if you desire), you could do something like this:
If you decided to go with column AA, then in AA1, type:
=MOD($E1, 1)
and fill down. Any real number can be divided by itself, so MOD will just return the remainder - which would be the fractional number that represents the time.
Your COUNTIF() formula will then look like:
=COUNTIF($AA1:$AA5,">="&TIME(15,0,0)) + COUNTIF($AA1:$AA5,"<="&TIME(4,0,0))
Inspired by some of the suggestions I came up with the following:
=SUMPRODUCT(
((A2:A17-TRUNC(A2:A17))>=0.625)*
((A2:A17-TRUNC(A2:A17))<=1))
+SUMPRODUCT(
((A2:A17-TRUNC(A2:A17))>=0)*
((A2:A17-TRUNC(A2:A17))<=(1/6)))
Edit: As per the other answer, it's easier to read with MOD instead of TRUNC:
=SUMPRODUCT(
(MOD(A2:A17,1)>=0.625)*
(MOD(A2:A17,1)<=1))
+SUMPRODUCT(
(MOD(A2:A17,1)>=0)*
(MOD(A2:A17,1)<=(1/6)))
Explanation:
A2:A17-TRUNC(A2:A17) returns only the decimal part of the number - time
0.625 - 15:00 (3 pm)
1 - midnight
0 - midnight
=0.166667 or 1/6 - 4:00 (4 am)
I'm sure there are other ways of doing it but this one seems pretty simple and does not require a helper column.

Get Value of first Pair

I have this file
Date | Time | Table | Checkin Time | Bill Number ..| .. |
7/1/2018 **18:03:48** **6** **18:03:48** **4332**
7/1/2018 18:11:23 **6** **18:03:48** **4332**
7/1/2018 18:23:10 **6** **18:03:48** **4332**
7/1/2018 19:24:11 8 19:24:11 4333
7/1/2018 19:56:17 8 19:24:11 4333
7/1/2018 20:31:11 *6 20:31:11 4332*
I need to calculate Checkin Time which is 1st time of table number and bill number.
For example See one customer checkin at 18:03:48 with table number 6
His Bill number is 4332 .
So for table number 6 and Bill number 4332 chekin time will be 1st time
which is 18:03:48.
So I applied the formula:
=IF(AND(E3=E2,C3=C2,A3=A2),D2,MIN(OFFSET(E3,0,-3,MATCH(0,(E3:E$35470=E3)*(C3:C$35470=C3)*(A3:A$35470=A3),0)-1,1)))
But the value changes at 6th row .
It's giving 20:31:11 as checkin time .
It should be 18:03:48 because the 6th row table number and bill number is same as 1st one.
So How do I make it possible, to calculate the checkin time as per 1st time who have same bill and table number , no matter which row .
Here is the excel file I have uploaded to Google drive.
Here is the screenshot.
Edit:- Formula by #jeeped work, But as the log is of 30 days
The data keeps repeating the other day too.
Can it be done by giving some unique date value ?
If you don't have the newer MINIFS and MAXIFS, use AGGREGATE to achieve the same result.
=AGGREGATE(15, 7, ((A$2:A$7)+(B$2:B$7))/((C$2:C$7=C2)*(E$2:E$7=E2)), 1)
Format the result any way you want; as date and time, time only, etc.
You can make use of an array formula combining INDEX+MATCH to return the earliest time value that matches your conditions first. In cell D2, enter the following:
=INDEX($B$2:$B$7,MATCH(1,($C$2:$C$7=C2)*($E$2:$E$7=E2),0))
When returning, be sure to press CONTROL+SHIFT+ENTER instead of just ENTER to make sure the formula calculates correctly.
#Jeeped's answer is spot on, here is an adjustment for the formula to work over multiple days that have the same table numbers and bill numbers:
=AGGREGATE(15, 7, ((A$2:A$13)+(B$2:B$13))/((C$2:C$13=C2)*(E$2:E$13=E2)*(A$2:A$13=A2)), 1)
All I did was add this extra conditional argument, that checks if the "Date" is the same:
*(A$2:A$13=A2)

EXCEL: what is the formula for getting the time remaining until tonight 00:00

I have a list of date and time, say 3/5/2018 15:00:00
I want a formula to calculate the time remaining until tonight 00:00
for this example, it should be 09:00:00
this is an image of the resulting table I wanted
what i tried: =TEXT(TIME(24,0,0)-A20, "hh:mm") the result is #Value!
The general algorithm for this, in any programming language or environment is simple:
Get the date component from the date-time value.
Increment the day value.
Subtract the date-time value from the date value in step 2
This works because the value from step 2 is still a date-time value, but the time-of-day component is now zero which represents that day's morning-midnight (i.e. 00:00 in the 24-hour clock).
In Excel, date, time, and date-time values are all represented by decimal numbers where the integer component represents a day-count after some epoch and fractional component represents the time-of-day.
This means step 1 is done by simply doing INT( date-time-value ).
And step 2 is done by simply adding +1 to that value.
And step 3 is simple subtraction, but be sure to set the cell's display format to "Time" and not Date or Date-Time.
Cell B2 should have this formula:
=( INT( A2 ) + 1 ) - A2
Then drag-fill that for the column to get the values for the other rows.
That's it.
So, did this, do note that my answer is in decimals... You can sort to hours, minutes and seconds...
=24-(HOUR(B4)+MINUTE(B4)/60+SECOND(B4)/3600)
This should do:
=24-TEXT(A20,"hh:mm")
Considering midnight is either 0 or 24, depending on where you come from, as we are moving towards it we consider as "24" and when we are moving from it, "0". So I subtract the current time/date in a format that excludes the date from "24" and there you have remaining time to midnight.
Do not forget to format the cell to "time", otherwise the results will be wrong.

Grab minimum time in year

As an athlete I want to keep track of my progression in Excel.
I need a formula that looks for the fastest time ran in a given season. (The lowest value in E for a given year. For 2017, for example, this is 13.32, for 2018 12 and so on.
Can you help me further?
Instead of formula you can use PIVOT
Keep the Year in Report Filter and Time into Value. Then on value field setting select min as summarize value by.
So every you change the year in the Filter the min value will show up.
=AGGREGATE(15,6,E3:E6/(B3:B6=2017),1)
15 tell aggregate to sort the results in ascending order
6 tells aggregate to ignore any errors such as when you divide by 0
E3:E6 is your time range
B3:B6 is you Year as an integer.
B3:B6=2017 when true will be 1 and false will be 0 (provide it goes through a math operation like divide.
1 tells aggregate to return the 1st value in the sorted list of results

Return corresponding date of max value

I'm looking for a formula which will give me the date of the last version of the order.
To illustrate, the sheet looks as follows:
A B C
1 Sales Order Version Date
2 SO#12345 1 21/02/2013
2 SO#12345 2 28/04/2013
3 SO#12345 3 04/08/2013
4 SO#12345 4 27/09/2013
5 SO#54321 1 02/03/2014
6 SO#54321 2 31/03/2014
7 SO#54321 3 07/10/2014
8 SO#54321 4 13/12/2014
So I would like to get the date of SO#12345, version 4 (29/09/2013).
I've tried several combinations of INDEX, MATCH, IF and MAX functions, but I can't seem to get the right value.
It either gives me the corresponding date of the highest value in the version column or it gives me the correct version number, but I can't make it show the appropriate date.
I did use CTRL+SHIFT+ENTER for these formulas, so they are executed as a matrix function.
Again, assuming the Order Number is in E2, try:
=LOOKUP(1,0/FREQUENCY(0,1/(1+(A2:A8=E2)*B2:B8)),C2:C8)
Regards
If the versions are listed in order for each Sales Order numberyou can use LOOKUP like this:
=LOOKUP(2,1/(A$2:A$8=E2),C$2:C$8)
Where E2 contains a specific order number
....or you can use the order number directly
=LOOKUP(2,1/(A$2:A$8="SO#12345"),C$2:C$8)

Resources