Excel two column and condition - excel

I have a column with dates like so where w represents weeks and d represents days.
Column1 Column2
in 1w3d out 1w5d
in 2w0d out 3w0d
in 24w2d out 23w0d
in 1w0d out 1w2d
Basically what I want to do is to check if both dates in Column 1 and Column 2 are between 1 week and 24 weeks. Both column values must be within the range.
Thus the output would be
Column1 Column2 Column3
in 1w3d out 1w5d Between 1 week and 24 weeks
in 2w0d out 3w0d Between 1 week and 24 weeks
in 24w2d out 23w0d Not between
in 1w0d out 1w2d Not between
I have an if statement for this written in excel that is like so
=IF(AND(A2>"in 1w0d,A2<"in 24w0d",B2>"out 1w0d,B2<"out 24w0d"),1,0)
However this does not get the desired results

Column3=MID(A2,SEARCH(" ",A2),SEARCH("w",A2)-SEARCH(" ",A2))*7+(MID(A2,LEN(A2)-1,1))
Column4=MID(B2,SEARCH(" ",B2);SEARCH("w",B2)-SEARCH(" ",B2))*7+(MID(B2,LEN(B2)-1,1))
Column5=IF(AND(C2>7,C2<24*7,D2>7,D2<24*7),1,0)
Maybe you need C2>=7 etc depending on where to draw the line

Related

Count specific column values by year in another date column in Excel

I have an excel table with two columns and several hundred rows. One column lists a single-digit code that represents an event, the other the date of that event. I'm attempting to count the number of times a particular event (say "1") occurred in a particular year (say 2017).
I normally use "COUNTIFS" for two or more criteria, but I'm stumped by the date format. I can't seem to get it to work in the formula. In this case, I'm using the yyyy-mm-dd format. How can I perform this operation?
A small example of the table is as follows:
------------------------
A B
--+--------------------+
1 Event Date
2 1 2016-09-12
3 1 2019-10-11
4 3 2017-03-24
5 2 2016-05-25
6 3 2017-08-02
7 1 2018-10-11
Just use
=COUNTIFS(A:A,1,B:B,">="&DATE(2017,1,1),B:B,"<="&DATE(2017,12,31))
EDIT:
if you have text-that-looks-like-dates, you can use SUMPRODUCT and YEAR:
=SUMPRODUCT((A2:A7=1)*(YEAR(B2:B7)=2017))

How to find values in one column in another column with multiple values

I have an excel like
A B START DATE END DATE
1 10 01-jan-2016 02-jan-2016
2 11 01- jan-2051 02-feb-2061
3 1 04-mar-2016 07-mar-2016
4 1 08-mar-2016 10-mar-2016
5 5 01-mar-2016 03-dec-2016
6 5 03-nov-2016 31-dec-4712
I am new to excel. I want to highlight or extract the columns in A column which can be found in B Column along with the start date and end date .
That is result should be like :
A start_date end_date
1 04-mar-2016 07-mar-2016
1 08-mar-2016 10-mar-2016
5 01-mar-2016 03-dec-2016
5 03-nov-2016 31-dec-4712
Can anyone pls suggest something ?
In E2 enter:
=IF(COUNTIF(A:A,B2)>0,"X","")
and copy down. Then filter the table
You can hide any un-wanted columns after that.

How to get the latest date with same ID in Excel

I want to Get the Record with the most recent date as same ID's have different dates. Need to pick the BOLD values. Below is the sample data, As original data consist of 10000 records.
ID Date
5 25/02/2014
5 7/02/2014
5 6/12/2013
5 25/11/2013
5 4/11/2013
3 5/05/2013
3 19/02/2013
3 12/11/2012
1 7/03/2013
2 24/09/2012
2 7/09/2012
4 6/12/2013
4 19/04/2013
4 31/03/2013
4 26/08/2012
What I would do is in column B use this formula and fill down
=LEFT(A1,1)
in column C
=DATEVALUE(MID(A1,2,99))
then filter column B to a specific value of interest and sort by column C to order these values by date.
Edit: Even easier do a two level sort by B then by C newest to oldest. The first B in the list is newest.
Do you need a programmatic / formula only solution or can you use a workflow? If a workflow will work, then how about this:
Construct a pivot table of your data
Make the Rows Labels the ID
Make the Values Max of Date
The resulting table is your answer.
Row Labels Max of Date
1 07/03/13
2 24/09/12
3 05/05/13
4 06/12/13
5 25/02/14

Count in Excel over a range using 2 columns of data

Tried looking for an answer first...
I want to count the number of items that were open between 1-7 days, 8-14 days, etc etc (open and closed on same day = open for 1 day)
Is there a way I can count this directly using the 2 columns holding the data without creating a 3rd column for Date Closed - Date Opened +1??
So in this example, what can I use to calculate that the number of 1-7 days items is 2? (Items 1 and 3)
Item # Open Closed
1 01/06/2014 01/06/2014
2 05/05/2014 20/06/2014
3 10/06/2014 16/06/2014
4 08/06/2014 15/06/2014
5 02/06/2014 19/06/2014
Many thanks :o)
One way would be to use the versatile SUMPRODUCT:
=SUMPRODUCT(1*(C2:C6-B2:B6+1>7))
assuming your start date column is B and end date column is C. The second part of the formula will determine all date spans which are larger than 7, and the 1* will convert the TRUE values to 1 in order to sum them up.

Excel weeknum conditional average

Date Number Weeknum
4-Jan-96 0.094288 2
5-Jan-96 0.092872 2
8-Jan-96 0.090431 2
9-Jan-96 0.153586 2
10-Jan-96 0.029758 3
11-Jan-96 0.052083 3
12-Jan-96 0.042797 3
15-Jan-96 0.047949 3
16-Jan-96 0.053029 3
17-Jan-96 0.051588 4
18-Jan-96 0.036755 4
19-Jan-96 0.043954 4
22-Jan-96 0.067316 4
I want the average number where weeknum is a certain value -edit(and year is a certain value) without averaging for every week by hand. Does anyone know whether there is an averageif/if/other condition that can do this? Weeknum doesn't always contain 5 consecutive values because holidays are preventing that.
Try this:
=AVERAGEIF(C1:C13;2;B1:B13)
Column C is the week number column.
Argument #2 is the week number you're interested in.
Column B is the column with the values to average.
Column A: date
Column B: value for the date
Column C: Weeknum for the date
Column E: Weeknumbers (1..52)
Column F: =SUMIF(C1:C10;E1;B1:B10)/COUNTIF(C1:C10;E1)

Resources