Count in Excel over a range using 2 columns of data - excel

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.

Related

EXCEL formula to sum demand per date when multiple entries of dates exist

How do I sum the amount of demand I have for each date, when there are multiple entries for each date., e.g.
Sheet 1:
A B
Date Demand
13/7/21 5
13/7/21 4
13/7/21 2
15/7/21 6
15/7/21 3
16/7/21 2
16/7/21 4
So I'm trying to get a summary as follows:
Sheet 2:
A B
13/7/21 11
14/7/21 0
15/7/21 9
16/7/21 6
17/7/21 0
I've tried =SUMPRODUCT(--('Sheet 1'!$A$2:$A$240='Sheet 2'!A2),'Sheet 1'!$B$1:$B$240)
I'm not wanting to do a pivot table, as the pivot table does not give me the zero values for dates where there is no data (unless there is a way to show this in a pivot)
You can use SUMIFS() like
=SUMIFS(Sheet1!B:B,Sheet1!A:A,A1)
You can also use SUMPRODUCT() in this way.
=SUMPRODUCT((Sheet1!$B$2:$B$8)*(Sheet1!$A$2:$A$8=A1))
Put together quickly to start you off:
Edit to give text version of the solution to the OP's problem:
=SUMIFS(B6:B12,A6:A12,"="&G12)
Then you can do between by setting lower and upper criteria in the sumifs().

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 create a ranged frequency table using Excel Cube functions

What I want is to create something like this (see image) in Excel that pulls in the frequency of my chosen category from a table within my PowerPivot data model. The output would also need to be dynamically filtered via a cell reference.
Using the below data set as an example:
Week 1 A
Week 1 A
Week 1 A
Week 1 A
Week 1 A
Week 1 B
Week 1 B
Week 1 C
Week 1 D
Week 2 A
Week 2 A
Week 2 A
Week 2 A
Week 2 A
Week 2 A
If I filtered to Week 1 through my set expression, the following output would be produced
1 2
2-4 1
5+ 1
However, if filtered to Week 2, this output would be produced
1 0
2-4 0
5+ 1
I say 'set expression' because I am assuming the way to do this is through the CUBESET function possibly with a MDX FILTER function and the CUBESETCOUNT functions though I am open to other suggestions. Even though the example doesn't show it, I need the expression to filter multiple dimensions from my cube, in particular, date, which is found in my calendar table.
I also understand that I could create specific measures within PowerPivot to handle this (sample formula below), but I would like to know if this is possible via the CUBESET function.
Freq (5+):=CALCULATE(
DISTINCTCOUNT([myColumn]),
FILTER(myTable,
COUNTROWS(FILTER('myTable', [myColumn] = EARLIER([myColumn]))) >=5 )
)
I am also open to creating a helper column within my Powerpivot table.
Thanks,

Sort by horodate on Excel

I would like to sort my Excel file by horodate so when we switch from summer time to winter time data is ordered by chronological order and so that when I create a graph the data is represented in the right order.
When i sort by horodate (from a to Z) i obtain that:
Horodate Value Chronological order
2014-10-26T01:30:00+02:00 32273345000 1
2014-10-26T02:00:00+01:00 28310393000 4
2014-10-26T02:00:00+02:00 31705207000 2
2014-10-26T02:30:00+01:00 27116547000 5
2014-10-26T02:30:00+02:00 29900587000 3
2014-10-26T03:00:00+01:00 26535312000 6
2014-10-26T03:30:00+01:00 26165805000 7
2014-10-26T04:00:00+01:00 26022551000 8
Which is not the chronological order as you see.. I would like to have 1 2 3 4 5 6 7 8
Thank you
You can add helper column and sort using it:
Formula in D1 (dragged down) is:
=SUBSTITUTE(LEFT(A1,19),"T"," ")-RIGHT(A1,5)*(MID(A1,20,1)&"1")
First part (SUBSTITUTE(LEFT(A1,19),"T"," ")) calculates date and time part, second (-RIGHT(A1,5)) timezone offset, and the third (MID(A1,20,1)&"1") sign of timezone offset (you can remove it, if there is always + in horodate).

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

Resources