Count number of occurences per day, months, quarter with Excel - excel

From a list of sales (colmuns A and B), how can I extract the number of sales per day, months, quarter with Excel ? (ie columns D, F, H)
I found some dirty code solution with
=SUM(DECALER(...; (LINE()-2)*31; 0; 31; 1))
(sorry I don't know english's translation for Excel's DECALER function)
but it would very annoying to have to distinguish between months of 30, 31, 28 days, etc.
Do you know a clean solution ?

You can use this formula to count for each month:
=SUMPRODUCT((MONTH($A$1:$A$10)=2)*(YEAR($A$1:$A$10)=2013))
And this for quarters:
=SUMPRODUCT((MONTH($A$1:$A$10)>=1)*(MONTH($A$1:$A$10)<=3)*(YEAR($A$1:$A$10)=2013))
I assume dates in A1:A10, the quarter example is for first quarter, for second replace 1 by 4 and 3 by 6

Pivot Tables are the easy answer to this.
But you could inesrt 2 columns after the date
and use this forumula to get the month name
=TEXT(A2,"mmm")
In the other column use this formula to get the Quarter
=ROUNDUP(MONTH(A2)/3,0)
Then you can use COUNTIF or SUMIF depening on what you need to get your totals

Thanks to the two proposed answers given by StevenMartin and CRondao, here is what might be the simplest solution :
= COUNTIFS($A:$A; ">=" & C2;$A:$A; "<" & C3 )
This can be copied in all cells of column D and F (and also cells of H, provided I replace Q3, Q4 quarter names by the date of the beginning of each quarter).

Related

SUMPRODUCT difference between two dates for THIS WEEK entries only

I have a column D containing all the Dates in DD/MM/YYYY format, and I would like to show the count of missed days for THIS WEEK values only from all the entries in column D.
In other words, if there is a difference between two Dates in column D and it occured this week, I would like to count it.
I have below formula to calculate "Total days missed" between first and the last entry in Dates column D, however I can't adopt this formula to display "Days Missed" for THIS WEEK only entries.
=SUMPRODUCT(--ISNA(MATCH(ROW(INDIRECT(MIN($D$18:$D$500)&":"&MAX($D$18:$D$500)));$D$18:$D$500;0)))
Sample of data set.
Please help, thanks.
For O365, in accord with your statement that there can be multiple entries of one date, I suggest the following (assuming your dates are real dates and not text strings that happen to look like dates):
Total Missing Dates
=MAX($D$18:$D$500)- MIN($D$18:$D$500)+1-COUNT(UNIQUE($D$18:$D$500))
Missing Dates THIS WEEK obviously, you'll need to define the first and last dates of THIS WEEK
=7-COUNT(FILTER(UNIQUE($D$18:$D$500),(UNIQUE($D$18:$D$500)>=wkStart)*(UNIQUE($D$18:$D$500)<=wkEnd)))
If your week starts on Monday, you can calculate:
wkStart: =TODAY()+1-WEEKDAY(TODAY()-1)
wkEnd: =wkStart+6
More generally, to return a particular day of the week prior to someDate (or wkStart):
wkStart = someDate - WEEKDAY(someDate - DayOfWeek)
where DayOfWeek is: Sunday=1 Monday=2 , etc
So, making someDate = TODAY()+1 ensures that if today is monday, it will return today and not the monday from a week ago.
HINT: It might be more convenient to define wkStart and wkEnd as a Named formula.

Excel COUNTIF "Column D" year equals 2015 and Column L equals "15 or greater"

I am able to count how many cells there are in Column D with year 2015. And I am able to count how many cells there are in Column L that are 15 or greater. However, I'm looking to combine these two formulas but I don't know how.
The formula I use to count the years is:
=SUMPRODUCT(--(TEXT('Sheet1'!D:D,"YYYY")="2015"))
The formula for counting 15 or greater is:
=COUNTIF('Sheet1'!L:L,">=15")
Can someone please provide a way I can combine these two formulas so I can count how many instances there was 15 or greater for the year 2015?
Thanks
COUNTIFS() with an S allows the ability of multiple criteria and you can bracket the dates:
=COUNTIFS('Sheet1'!L:L,">=15",'Sheet1'!D:D, ">=" & DATE(2015,1,1),'Sheet1'!D:D, "<=" & DATE(2015,12,31))
If your dates are actually text strings that look like dates you can do:
=COUNTIFS('Sheet1'!L:L,">=15",'Sheet1'!D:D,"*2015*")

Counting unique values in a column that matches multiple criteria in a single column

I'm trying to count how many values in column A multiple multiple criteria that are mixed in column B. I was able to do this using a helper column (column C). To better get the idea, please see below:
Row Column A Column B Column C
Day Shift Helper
1 Monday Worked AM Worked PM
2 Tuesday Worked AM
3 Wednesday Worked AM Worked PM
4 Monday Worked PM
5 Wednesday Worked PM
Column A contains days from Monday to Wednesday, column B contains shifts while column C contains a formula to return "Worked PM" if that day also has a "Worked PM" somewhere below. Basically, Monday and Wednesday has these in rows 4 and 5.
Formula for cell C1 is =IF(B1="Worked PM","",IF(COUNTIFS($A$1:$A$5,$A1,$B$1:$B$5,"Worked PM")>0,"Worked PM",""))
The reason why I have this helper column is because I want to count the days that have both "Worked AM" and "Worked PM" on them. In our example, the count formula should return 2. I used the following formula, which is working perfectly: =COUNTIFS($B$1:$B$5,"Worked AM",$C$1:$C$5,"Worked PM")
However, I wish to completely eliminate the helper column (column C), which I have failed to do ever since. I tried making use of SUMPRODUCT, COUNT+MATCH and COUNTIFS. I've seen tutorials on how to do this from different Excel help sites, but I've seen nothing that matched my concern. They were "close" (not sure), but when I reconfigure them, I always fail.
I've turned to here as my last stop before giving up. I want to ask if what I'm actually doing is impossible. If it is possible, I would as well seek your guidance on how can I arrive on the solution. Thanks in advance! :)
This will replicate the results from your helper column method. Enter as an array formula (ctrl+shift+enter):
=SUM(--IF(B2:B6="Worked AM",IFERROR(MATCH(A2:A6,IF(B2:B6="Worked PM",A2:A6),0),0)>0))
But unless you have duplicate row entries, wouldn't the count simply equal the number of repeats you have in column A? You don't have to enter this as an array formula:
=SUM(--(FREQUENCY(MATCH(A2:A6,A2:A6),ROW(A2:A6)-ROW(A2)+1)>1))

Excel AverageIf to get total average of multiple rows from a table

I have provided a simple example of what I would like to do. I tried to use AverageIf to get the average of all Monday sales for March and April but the formula only provides me the average of March's Monday sales and excludes April.
Note: Column A is Weekday number, Column B is March Sales, Column C is April Sales.
This is the formula I used:
=AVERAGEIF(A2:A200, "=" & 1, B2:C200), which only provides me with average Monday sales in column B.
How can I adjust the formula to also include April in the total average (i.e. take into account column C rather than just column B alone)
Rather than using AverageIf(), try using Average(If()) as an array formula for this kind of scenario.
In your scenario, you could use the following formula to get the average:
=AVERAGE(IF(A2:A200=1,B2:C200))
ENTERED AS AN ARRAY FORMULA using cntrl + shift + enter
Hope that helps.

How to get the week number of the year from the date range in an Excel Pivot Table

Hi I would like to know a formula where I can convert a grouped date range into the week number of the year. For example column A has the date ranges. I want column B to have the week number. So it will be like the example below
Column A Column B
31/12/2013 - 06/01/2013............................................Week 1
07/01/2013 - 13/01/2013............................................Week 2
Thanks to anyone who can solve this. Its been bugging me out
You could perhaps use something like that:
=(RIGHT(A2,10)*1-41273)/7
This takes the last date in that date range, turns it into a number and subtracts 41273 (which is the equivalent of 1st January 2013) and divides the result by 7.
If you want to specifically get Week 1, you can either use custom formatting with "Week "#, or if you want the literal Week, you can use ="Week "&(RIGHT(A2,10)*1-41273)/7

Resources