I am using index/match to extract data by matching date/times using INDEX(D:D,MATCH(A2,B:B,0))
A:A column of date/times has been manually entered.
B:B column of date/times input as B2+time(,30,) and copied down.
After 3 lines the formula gives #N/A as an answer.
It has something to do with the times not matching exactly even though A5=B5 gives a true result that row gives #N/A
If I copy A:A to B:B i.e. all manually entered times it works perfectly.
Please help.
A B C D E F G H I J K
AET Entered AET + 30 = volts lo i1 i0 vl1 vl0 Value AET Value Time +30
1/08/15 10:00 1/08/15 10:00 TRUE 36 36 36 36 36 36 42217.4166666667000 42217.4166666667000
1/08/15 10:30 1/08/15 10:30 TRUE 23 23 23 23 23 23 42217.4375000000000 42217.4375000000000
1/08/15 11:00 1/08/15 11:00 TRUE 44 44 44 44 44 44 42217.4583333333000 42217.4583333333000
1/08/15 11:30 1/08/15 11:30 TRUE 55 44 44 #N/A 44 #N/A 42217.4791666667000 42217.4791666667000
1/08/15 12:00 1/08/15 12:00 TRUE 13 55 55 #N/A 55 #N/A 42217.5000000000000 42217.5000000000000
1/08/15 12:30 1/08/15 12:30 TRUE 32 13 13 #N/A 13 #N/A 42217.5208333333000 42217.5208333333000
1/08/15 13:00 1/08/15 13:00 TRUE 56 32 32 #N/A 32 #N/A 42217.5416666667000 42217.5416666667000
1/08/15 13:30 1/08/15 13:30 TRUE 70 56 56 #N/A 56 #N/A 42217.5625000000000 42217.5625000000000
1/08/15 14:00 1/08/15 14:00 FALSE 43 70 70 #N/A 70 #N/A 42217.5833333333000 42217.5833333334000
1/08/15 14:30 1/08/15 14:30 TRUE 31 43 43 #N/A 43 #N/A 42217.6041666667000 42217.6041666667000
1/08/15 15:00 1/08/15 15:00 TRUE 21 31 31 #N/A 31 #N/A 42217.6250000000000 42217.6250000000000
1/08/15 15:30 1/08/15 15:30 FALSE 11 21 21 #N/A 21 #N/A 42217.6458333333000 42217.6458333334000
1/08/15 16:00 1/08/15 16:00 TRUE 66 11 11 #N/A 11 #N/A 42217.6666666667000 42217.6666666667000
1/08/15 16:30 1/08/15 16:30 TRUE 45 66 66 #N/A 66 #N/A 42217.6875000000000 42217.6875000000000
1/08/15 17:00 1/08/15 17:00 FALSE 23 45 45 #N/A 45 #N/A 42217.7083333333000 42217.7083333334000
I'll leave #AxelRichter to post the answer in his comment, which involves rounding the timestamps and referencing the rounded numbers to avoid floating point precision.
An alternative solution would be to simply allow VLOOKUP/MATCH to pick up the 'nearest value' result, using the final argument in each function. ie:
=INDEX(D:D,MATCH(A2,B:B,1))
Keep in mind that this will only work if your data is sorted. It has the added benefit that if a missing result should naturally be the next closest row, that row is picked up - and likewise it has the added cost that it will not warn you when a match isnt found.
This is an issue with floating point precision. As you see even the = comparison fails with 1/8/15 14:00 42012,5833333333 vs. 42012,5833333334. The exact matching with MATCH(..,0) or VLOOKUP(.., FALSE) uses an other comparison method and so it fails more often. If we need exact matching date time values then we need those values ROUNDed the same count of decimals. So we need helper columns which ROUNDs A and B to 8 decimals and then use those helper columns in MATCH(..,0) or VLOOKUP(.., FALSE).
At least one helper column is needed since we could round the lookup value directly within the functions. But the lookup array we can not round that way.
Example:
Formulas:
B3downwards:
=B2+TIME(0,30,0)
C2downwards:
=A2=B2
D2downwards:
=MATCH(B2,A:A,0)
E2 downwards:
=MATCH(ROUND(B2,8),G:G,0)
G2downwards:
=ROUND(A2,8)
Related
I would like to sum the sales depending on the time diapasons of the day-night in which they occur. For example, I would like to sum all sales that happened between 22:00h and 2:00h.
Hour Sales
18:58 49
18:00 49.5
03:01 31
20:00 139
09:15 61.5
11:36 5
08:00 24
16:32 25
12:30 96.5
17:30 75.5
09:00 80
00:10 24
15:00 24
18:00 216
09:30 24
06:30 47.5
So if I try to do a sumifs where the hour is >=22:00 and <23:00, the formula works. However, if I try to sumifs the values between 22:00 and 2:00, in other words the first criteria is ">=22:00" and the second is "<2:00", the sumifs cannot work. I do understand why but I'm struggling to find an alternative way to solve this task.
As stated, we need to add 1 when it rolls to the next day, which means SUMPRODUCT:
=SUMPRODUCT($B$2:$B$17,((E2<D2)+$A$2:$A$17>=D2)*(($A$2:$A$17<D2)+$A$2:$A$17<(E2<D2)+E2))
I'm trying to create a dynamic rolling 12 month cash flow in Excel.
Lets say the month name is in cell A1.
Underneath cell A1 l have a list of cash flow expenses in my rows and the expenses listed in the columns by month. I have a separate column at the end that totals up 12 months of expenses based on the month name (in cell A1).
So, if cell A1 says Jun-18, l want to add up the expenses for each row item from Jun-18 to May-19. OR say, if cell A1 says Sep-18, l want to add up the expenses for each row item from Sep-18 to Aug-19.
I don't know how to do this, can anyone please advise.
Thanks for your help,
M
You can use sum ofset match
Given the example data below (as I think that you have described in your question), you can use the the following formula (this example the formula result is showing in B2) A1 contains the start date to calculate from.
=SUM(OFFSET(A2,MATCH(A1,A2:A100)-1,4,12,1))
You will need to research how ofset works, as I currently do not have time to explain, but to help you use this formula within your worksheet you will need to change the number 4 which is 4th column away (column E containing the months totals) from the matched date.
The 12 in the formula shows how many rows down you want to sum.
A B C D E
1 Jul-18 8638.21
2 Expence1 Expence2 Expence3 Total
3 Jan-18 1 1 1 3
4 Feb-18 2 2 2 6
5 Mar-18 3541 531 51 4123
6 May-18 100000 31 351 100382
7 Jun-18 846 8 321 1175
8 Jul-18 1 153 12 166
9 Aug-18 0 8 21 29
10 Sep-18 0 65 8 73
11 Oct-18 54 321 1 376
12 Nov-18 321 123 1 445
13 Dec-18 1 321 2 324
14 Jan-19 546 0 51 597
15 Feb-19 132 51 15 198
16 Mar-19 12 321 51 384
17 Apr-19 51 123 321 495
18 May-19 5161 3.21 351 5515.21
19 Jun-19 21 3 12 36
20 Jul-19 321 1 1351 1673
Two columns, one with ID and one with values. I want to calculate average per ID. The number of rows per ID is not constant. What i have:
ID Value
1 22
1 31
1 34
1 23
1 31
34 67
34 65
34 55
12 44
12 46
12 43
12 35
I want a formula which will calculate third column:
ID Value Average per id
1 22 28.2
1 31 28.2
1 34 28.2
1 23 28.2
1 31 28.2
34 67 62.3
34 65 62.3
34 55 62.3
12 44 42.0
12 46 42.0
12 43 42.0
12 35 42.0
I have tried AVERAGEIF function but i cant figure it out.
Just use these formulas:
=AVERAGEIF(A:A,A2,B:B)
or
=SUMIF(A:A,A2,B:B)/COUNTIF(A:A,A2)
Column A are dates and B & C are Measurements
Dates Measurements
1 56 15
2 45 25
3 62 76
4 15 42
5 165 56
6 16 79
7 45 46
8 47 79
9 24 47
10 12 14
11 147 47
12 195 19
13 443 79
14 642 43
15 462 75
16 156 87
17 794 49
Start Date:2
Measurement:45
Code used to solve for the measurement
=VLOOKUP(B21,A2:C18,2,FALSE)
end date:14
Measure:642
=VLOOKUP(B22,A2:C18,2,FALSE)
I used vlookup to find me the values that I desire, but now I want to find the median values of that range from the start to end date in each column.
How can I code it so that once it selects the values, it can select the whole range and find the median values?
Since your column A values are ordered ascendingly, we can use the very efficient:
=MEDIAN(INDEX(B2:B18,MATCH(B21,A2:A18)):INDEX(B2:B18,MATCH(B22,A2:A18,0)))
Regards
Here is a sample from the data that I am looking at.
Hour Index Visits
0 67
1 22
2 111
3 22
4 0
5 0
6 22
7 44
8 0
9 89
10 22
11 111
12 44
13 89
14 44
15 111
16 177
17 89
18 44
19 44
20 89
21 22
22 89
23 44
24 133
25 44
26 22
27 22
28 44
29 22
30 44
31 44
32 22
what I want to do is add another column that contains dates starting with Monday which is repeated 24 times then go to Tuesday (repeated 24 times) and so on. So the result should look like:
Hour Index Visits Day
0 67 MONDAY
1 22 MONDAY
2 111 MONDAY
3 22 MONDAY
4 0 MONDAY
5 0 MONDAY
6 22 MONDAY
7 44 MONDAY
8 0 MONDAY
9 89 MONDAY
10 22 MONDAY
11 111 MONDAY
12 44 MONDAY
13 89 MONDAY
14 44 MONDAY
15 111 MONDAY
16 177 MONDAY
17 89 MONDAY
18 44 MONDAY
19 44 MONDAY
20 89 MONDAY
21 22 MONDAY
22 89 MONDAY
23 44 MONDAY
24 133 TUESDAY
25 44 TUESDAY
26 22 TUESDAY
27 22 TUESDAY
28 44 TUESDAY
29 22 TUESDAY
30 44 TUESDAY
31 44 TUESDAY
32 22 TUESDAY
I know how to get the dates to increment, but not repeat 24 times then increment. Can someone show me how to do this with Excel?
try to use this formula (I suppose that your Hour column starts from A2 cell):
=TEXT(1+MOD(1+INT(A2/24),7),"dddd")
Note, that formula works well if your excel dates starts from 01.01.1900 (which is usually default for excel on PC).
If you are using 1904 date system, you should use next formula:
=TEXT(2+MOD(1+INT(A2/24),7),"dddd")
Please try: =UPPER(TEXT(DAY(2+A2/24),"dddd")). The first 2 is to control when the sequence starts.