SUMIF and DATEDIF by row - excel

I have a row of dates, with one date per column. Dates are in order from oldest to newest. I am trying to count only those where the difference is 14 days or greater. I need it to count by row
Date A | Date B | Date C | Date D | 2
So Date B - Date A = 13| Date C - Date B = 29| Date D - Date C = 15| 2
The formula should return 2, since the first was less than 14 days.
I've spend hours on various forums with no luck. I never post since I am usually able to figure my problems out by reading other's kind posts & suggestion. I appreciate whatever help comes my way.

You can do it with SUMPRODUCT:
=SUMPRODUCT(--(B1:D1-A1:C1>=14))
Note the offset but same size ranges.

If you use a helper row, you can combine simple subtraction with a COUNTIF():
So in A2, put =B1-A1 and drag right.
Then in E2: =COUNTIF(A2:D2,">=14")

Related

FInd min Date in a date range with duplicate date

Using Excel and I'd like a formula that will return the earliest date from a row that contain duplicate date.
for example:
my row has 5 different dates, 1 duplicate and one blank cell
A B C D E F
09/01/2021 08/28/2021 09/08/2021 blank cell 09/01/2021 08/15/2021
I am using formula =MIN((A1:F1)
the return should be "8/28/2021" but I'm getting "1/1/1900"
can someone please help? that will be greatly appreciated
Try this:
=MIN(IFERROR(A1:F1*A1:F1/A1:F1,99999))
It will replace all the 0's with 99999 if it cannot be divided by itself (0).
(99999 is actually 10/13/2173 and was chosen at random as a date that will be later than the other dates on your list.)
You can do it with SMALL function:
SMALL function
My formula in column J is =SMALL(A1:G1;1)
Notice my date format is dd/mm/yyyy

Dynamic Average Orders Per Day Counter By Date

I have been having some trouble figuring this out for the last hour, I hope one of you can help me out :)
So I have figured out the formula to calculate the average orders per day like so:
{=COUNTA(A2:A7)/SUM(1/COUNTIF(A2:A7,A2:A7))} 'PRESS (CTRL + SHIFT + ENTER)'
DATA:
A
1 | ORDER DATE
2 | 12/05/2019
3 | 12/05/2019
4 | 12/05/2019
5 | 15/05/2019
6 | 16/05/2019
7 | 22/05/2019
8 |
9 |
10|
RESULT:
1.5
My formula works fine to calculate only until A7. How would I make the formula dynamic so that it can calculate future data entries until A10 and/or infinity down the A column?
Thank you
The cell with the last date in column A can be retrieved with,
index(A:A, match(1e99, A:A))
Put this into your formula like,
=COUNTA(A2:index(A:A, match(1e99, A:A)))/SUM(1/COUNTIF(A2:index(A:A, match(1e99, A:A)), A2:index(A:A, match(1e99, A:A))))
This is a non-volatile solution (unlike OFFSET). It will only recalculate when something that affects the formula changes; not when anything in the workbook changes.
Try,
A2:A7 -> OFFSET(A2,,,COUNTA(A:A)-1)
= COUNTA(OFFSET(A2,,,COUNTA(A:A)-1))/SUM(1/COUNTIF(OFFSET(A2,,,COUNTA(A:A)-1),OFFSET(A2,,,COUNTA(A:A)-1)))

Excel - Return dates in a list that are within 1 year of another date

I'm trying to write a formula that would return a date (B) from a list if that date is within 1 year of another date (A). If there are no dates in the list that are within 1 year of date A, then date B will simply be date A plus 1 year (365.25 days).
For example: My list is [2/15/16, 12/26/17, 5/15/19]. If date A is 1/1/16, then I want Date B to equal 2/15/16. If Date A was 2/15/16, then Date B would be 2/15/17.
The closest I've gotten is:
=IF(MIN(L:L)-A<=365.25,MIN(L:L),A+365.25), but obviously this won't work beyond the minimum date. I need to check against the whole list of dates, not just the minimum date.
My end goal is to make a list like this (column A after the first date is just the previous B:
From (A) - To (B)
1/1/15 - 1/1/16
1/1/16 - 2/15/16
2/15/16 - 2/15/17
2/15/17 - 12/26/17
Thanks for any tips in advance!
If I understand correctly, this should work
=IFERROR(LOOKUP(2,1/((($A$2:$A$4-C2)<365.25)*(($A$2:$A$4-C2)>0)),$A$2:$A$4),EDATE(C2,12))
Column A has the list of dates, C2 has Date A. Running some more dates in column C, copying the formula down:

Sumif Function involving dates and text

I have a three columns which contain a range of dates, ie 6/15/2013, corresponding items ie. gravel, asphalt etc and corresponding tonnages. I need to be able to sum all of the tonnages of asphalt per month.
I have tried several sumif statements but they are all coming back with no value. Everything was going fine until I tried to add the sorting by month "if" statement.
Any help is appreciated.
Sample Data below
Column A | Column B | Column C
6/23/2013| Asphalt | 12
7/14/2013| Asphalt | 14
6/15/2013| Gravel | 15
8/15/2013| Gravel | 18
6/3/2013 | Asphalt | 14
thanks
If you have Excel 2007 or later try using SUMIFS, e.g. in F2
=SUMIFS(C:C,B:B,"Asphalt",A:A,">="&E2,A:A,"<"&EOMONTH(E2,0)+1)
where column A contains dates, B items and C tonnages....and E2 should contain the 1st of the month for which you want to sum. You can add more more dates in E3 down and then copy that formula down

Excel: Matching the closest date from range of dates

I'm trying to display the header of the column that its cell that contains a date, is the closest (out of 3 other cells with dates, B2:D2) to the a specific cell (A2)
So here's my sheet:
A B C D
1 | T1 | T2 | T3 | T4 |
2 | 5/1/2013 | 5/31/2013 | 2/5/2013 | 3/2/2013 |
A2 = a date.
B2:D2 = 3 dates, can also be blank
I've tried using the following array formula that I found online:
=IF(COUNT($B2:$D2)>0,INDEX($B$1:$D$1,MATCH(MIN(ABS($B2:$D2-$A2)),ABS($B2:$D2-$A2),0)),"")
But it sometimes when there is only one or two dates, it gives me the wrong header. I would also like to avoid using array formulas, but couldn't convert it to a regular one.
Would highly appreciate assistance on this matter
Can you give an instance were the array formula you are using isn't working ? It worked for the cases I tried.
You can avoid using the array formula if you are prepared to have another row with the difference in the dates and your date cell A2.
Push your rows down one row, so the headings are on row 2 and the dates on row 3 and enter the following formula across row 1, starting at cell B1
=ABS(B3-$A$3)
Drag this across and enter the following HLOOKUP to get your header row
=HLOOKUP(MIN(B1:D1),B1:D3,2,FALSE)
if you can't move your rows down for some reason you can use a combination of MATCH and INDEX (which is slower) . If you were to put the difference function =ABS(B2-$A$2) across row 7 the formula would be
=INDEX(B1:D1,1,MATCH(MIN(B7:D7),B7:D7,0))
Okay so the answer was fairly simple.
I went back to the sheet to investigate the scenarios in which this happens.
It seems that when A2 is blank (= no date to make the comparison) it just gives out the only date available from B2:D2.
By simply adding another condition to the IF statemented that would work only if A2 has a value resolved the issue. So we're checking if both A2 and B2:D2 has values in them (with B2:D2 needs to be at least one:
=IF(AND(COUNT($B2:$D2)>0,$A2>0),......)
and here is the full formula
=IF(AND(COUNT($B2:$D2)>0,$A2>0),INDEX($B$1:$D$1,MATCH(MIN(ABS($B2:$D2-$A2)),ABS($B2:$D2-$A2),0)),"")
Thanks for making me go back to the investigate! :D
For a non-array alternative, you could try:
=LOOKUP(2,1/FREQUENCY(0,ABS(B2:D2-A2)),B$1:D$1)
in place of the INDEX(...) part of the formula.

Resources