IF statement to calculate days between dates if column contains date - excel

I have two columns, Last Upload and Final Date. I have a formula to calculate the difference between today and the Last Upload using
=DATEDIF( [#[Last Upload]],TODAY(),"d")
However, sometimes the Last Upload column will be blank and in this case we would like to use the Final Date column instead.
Is there a way to combine and use the above statement when the column is not blank and the other when it is? I have been trying to nest it with an IF statement but struggling to do so.

You could use ISBLANK formula combined with IF formula.
=DATEDIF(IF(ISBLANK([#[Last Upload]]),[#[Final Date Upload]],[#[Last Upload]]),TODAY(),"d")

Alternative solution:
=DATEDIF(IF(LEN([#[Last Upload]]),[#[Last Upload]],[#[Final Date]]),TODAY(),"d")
LEN might be a little bit more error-proof than ISBLANK.

Related

Excel Date Countifs

I need to count all dates that are "less than" today to see which work is overdue. I understand that this can be done simply with
=countif(F:F,"<"&TODAY())
However, the dates in Column F are formatted like "12/05 - Evening" instead of just "12/05". Because of this, the formula is not picking up anything. Does anyone know how to change this code so that it counts any cell that contains dates prior to today, even if there is other text in the cell? I've tried playing around with these "**", but can't get it to work.. Thank You!
So based on my comment I would get the date by using left() with find() like so:
LEFT(A1,FIND(" ",A1,1)-1)
Then format as short date and it behave as a date.
From comment:
Use a helper column and separate the date out then use the countif() on that column

Excel round multiple dates to a single one

I'm trying to put multiple rows which contain a date of the month between the first and last day of the month and I want to put them togeather as the first of the month dpeending on which month they are in:
for example; if they have the month of 12 i want to make them the 01/12/2020 if it was november 01/11/2020 and so on...
What i am looking for is to get three or more dates into a single one:
Date
03/12/2020
16/12/2020
27/12/2020
And make it:
Date
01/12/2020
Thanks for any help on how i could go about this, im struggling to find a solution
(I have tried text join and concatenate and neither work)
If you have Excel365 then use-
=DATE(2020,UNIQUE(MONTH(A1:A4)),1)
If you have dates with different years then try below formula.
=DATEVALUE("01-"&UNIQUE(TEXT(A1:A4,"mm-yyyy")))
Pretty unconventional way of doing it but works:
=EOMONTH(EDATE(AVERAGE(A1:A12),-1),0)+1
Where A1:A12 is a range of dates.
You have not specified well whether your dates are strings or actual Excel dates. Nor is it clear to me whether this is an example of a single cell in a larger row. The solution would be different based on the answer to these questions (which I do not have enough reputation to put as comments).
If you already have these values as dates put a new value in an adjacent column. Assuming the existing date value is in cell A1:
=DATE(YEAR(A1), MONTH(A1), 1)
However, if the date value is actually a string you will need to hard code the extraction of the values. Assuming, the are in fixed length strings as your image shows, with dd/mm/yyyy format:
=DATE(RIGHT(A1, 4), MID(A1, 4, 2), 1)

SUMPRODUCT several ifs

I´ve spent a lot of time with a formula in Excel and I´m still blocked. I hope you can help me.
I have a table in Excel with several values as shown in this
screenshot.
What I´m trying to extract is the number of Fruits sold in a specific month. That is, how many lemons were sold in January 2016, for example. This is the formula I´m using:
=SUMPRODUCT((B3:B38=E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
But the result is #N/A as seen in the screenshot.
What Am I doing wrong? Any help, please?
Thanks a lot in advance!
You can use arrays in excel to get this answer
{SUM(IF(MONTH(F$3&"1")=MONTH($A$3:$A$150),IF($E4=$B$3:$B$150,$C$3:$C$150,0),0))}
You can use this Sumproduct formula which uses array logic:
SUMPRODUCT((MONTH($A$3:$A$38)=MONTH(TEXT(G$2,"MMM")&1))*($C$3:$C$38=$F4)*
($D$3:$D$38))
Sumproduct Demo
Part of your problem is your ranges are not equal in length. B3:B38 has to be the same number of rows as $A$3:$A$150 and C3:C150. When rows are not equal things blow up on you.
=SUMPRODUCT(($B$3:$B$150=$E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
if you change your header row to be actual excel date format, and then change the cell display format to just show the month (as suggested by csanjose), then you can adjust your sumproduct formula as follows and copy to all cells in your table.
=SUMPRODUCT(($B$3:$B$38=$E4)*(MONTH($A$3:$A$150)=Month(F$3))*(YEAR($A$3:$A$150)=Year(F$3));$C$3:$C$150)
Fill your month-row with the last day of each month, then apply date format to show only month name.
The formula you should use is, for example, in g8:
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&G$3;$A:$A;">"&F$3)
First column "F" doesn't have a column on the left to compare, so you can put a date in E3 or change a bit the formula (example of F8):
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&F$3;$A:$A;">2015/12/31")
Take a look at the result
If you don't want to use a pivot table, you can use this formula to get what you need:
=SUMPRODUCT(($B$3:$B$150=$E3)*(MONTH($A$3:$A$150)=1)*(YEAR($A$3:$A$150)=2015)*$C$3:$C$150)
Then drag-fill the cell to copy it to every month column (just make sure you change the month number in the formula (and year if you're doing that too)), and then drag-fill down the columns.
That should work pretty food good :)
Good Luck!

Compare dates with IF

Three columns below, I'm attempting to use column C as a formula that checks against a hard coded date.
8/18/14 12/19/20 formula
In column C =IF(AND("10/7/15">=A1,"10/7/15"<=B1),"IN","OUT")
What I'm looking for is to tell if 10/7/15 is between 8/18/14 & 12/19/20 - I would expect that to come back with a value of IN but it doesn't.... hoping its something simple I'm missing
I think the problem is you're comparing a date (which translates to a number) to a text string. It's a crap-shoot as to what Excel will do in this case. If you compare a date to a date, I believe you will get the desired behavior:
=IF(AND(DATE(2015,10,7)>=A1,DATE(2015,10,7)<=B1),"IN","OUT")
The datevalue function should also work.
If you really have a date in A1, you can try:
=IF(AND(VALUE("2015-10-07")>=VALUE(A1),VALUE("2015-10-07")<=VALUE(B1)),"IN","OUT")

How do I add a third criteria to this Excel formula?

Here is the formula I am using:
{=INDEX(AA$1:AJ$1831,MATCH(1,(AA$1:AA$1831=C2)*(AD$1:AD$1831=O2),0),10)}
It finds a number based on matching a name and hour of day. I need to refine this to also match day of week. The problem I am running into is that the day of the week is part of a string. Either "Sat,Sun" or "Mon,Tue,Wed,Thu,Fri".
How do I add to the formula above? to make:
{=INDEX(AA$1:AJ$1831,MATCH(1,(AA$1:AA$1831=C2)*(AD$1:AD$1831=O2)*(SEARCH(P2,AC:AC)),0),10)}
Please try:
{=INDEX(AA$1:AJ$1831,MATCH(1,(AA$1:AA$1831=C2)*(FIND(P2,AC$1:AC$1831)>0)*(AD$1:AD$1831=O2),0),10)}
Since you are looking for a number why not use SUMIFS to return a single value from a column based on multiple criteria? Arrays are old school and the SUMIFS function can accomplish the same. Search criteria can take on wildcards or use formulas like Mid,left, or right to strip a partial value out of a string.
Give it a try and reply back if you are still having problems.

Resources