Find Dates and Sum - excel

I'm stumped. I'm currently trying to create a time off tracker for time off.
I have two tabs.
First tab: "Overview" - This tab has three columns.
Month
Amt Used
=SUMIFS(Data!$C:$C,Data!$A:$A,"January")
This formula access the data tab, and uses the first column information and sums the amount for that month.
Amt Left
Jan
=B5+$G$4
Feb
=C5+B6+$G$4
This adds the amount left, with amount used and adds the accrual rate with it each month.
Then to the right, I have "Accrual Rate" and the cell next to it is variable. It is the place to put the amount of hours accrued in a month. (The forumla will multiple it by 12 months to simplify for the user)
Done with first tab.
Second tab: Called "Data"
This is where one can put their days off.
This is nothing fancy. Three untitled columns.
a cell with a formula:
=IF(B1="","",TEXT(B1,"mmmmmmmm"))
Next column is the date in mm/dd/yyyy format.
Next column is the amount of hours used. Negative for "using hours" and positive number for "gaining hours".
Now, maybe I did not need a long explantion to ask this question. I'm trying to remove the column that figures out the month. Is there a way to use the Sumif command to find by date within the formula?
If the dates are:
1/1/2013 | -8 |
1/2/2013 | -8 |
1/3/2013 | -8 |
1/4/2013 | -8 |
2/2/2013 | -8 |
2/3/2013 | -8 |
2/4/2013 | -8 |
Is there a way to say, if the month is "1" or Jan, sum the total of the cell next to it? In this case, the answer should be 32.

With SUMIFS you could sum between 1st and 31st Jan, e.g.
=SUMIFS(Data!$C:$C,Data!$B:$B,">="&DATE(2013,1,1),Data!$B:$B,"<="&DATE(2013,1,31))
or probably better to reference a cell with the date, so say you have 1st Jan 2013 in B3 in Overview tab that would be:
=SUMIFS(Data!$C:$C,Data!$B:$B,">="&B3,Data!$B:$B,"<="&EOMONTH(B3,0))
The latter formula can be copied down for multiple months

Related

In Excel how to count between date1 and date2 that have cells in row that contain text?

I need to choose cells in one column that are between two dates, and then based on the rows that contain those dates, choose cells in another row that also contains content.
I didn't use ISBLANK because it counts a formula yet an empty cell as a not-blank. Instead check if there is content by "*".
Here is what I came up with, but instead of returning the number of cells, instead this returns TRUE (which obviously isn't what I want).
In the formula below I am assuming:
C:C is the whole column containing DATES.
E:E is the whole column containing CONTENT.
The date range in this case is January 1, 2018 to January 31, 2018.
"*" means is there is content in the cell
=IF(AND(COUNTIFS(C:C,">="&"2018-1-1",C:C,"<="&"2018-1-31"),COUNTIF(E:E,"*"))=0,"",AND(COUNTIFS(C:C,">="&"2018-1-1",C:C,"<="&"2018-1-31"),COUNTIF(E:E,"*")))
My goal is to:
count the numbers of the cells in column E that are between the dates in column C
if the whole formula is 0, then return a blank.
See this picture of a sample excel sheet to make my intent clear:
How can I get my formula working so it does as needed?
SOLUTION
Hi all, so thanks to #girlvsdata, we have a working solution. I had to do a couple edits to her code to work for my uses, but her formula overall works perfect. Here is the solution:
To choose all cells in column E that are not blank, in between the date range of all of January (unknown end date) based on the adjacent C column if that is your date column, then the solution is:
=IF(COUNTIFS(C:C,">="&"2018-1-1",C:C,"<="&EOMONTH("2018-1-1",0),E:E,"*")=0,"",COUNTIFS(C:C,">="&"2018-1-1",C:C,"<="&EOMONTH("2018-1-1",0),E:E,"*"))
Note that "2018-1-1" is January 1 2018, and EOMONTH("2018-1-1",0) is the last valid day of January in the year 2018 (in this case, 31, but if it is different another year (e.g. for February this works for leap years too) then it will be that last day). Also it eliminates the need to calculate which is the last day or every month, as well as months that have changing end dates dependent on the year (e.g. Feb). This is important to eliminate a margin of error.
The only thing you have to do to change the month is only change e.g. -1- (Jan) to -2- for Feb, or change the year for other years. With this formula you can ignore the day part.
If the answer is 0 (no cells have any content in between the range), then the cell is blank instead of 0. (GOod for when you want to create a sheet checking future dates for future reference when more rows are added to the sheet.
It also works across different sheets, just use, say your other sheet is called "Tracker" then use Tracker!C:C and Tracker!E:E. Hope it helps!
Thank you all! :D
(Please note: My local date format is day, then month)
With the data laid out as in your example above:
A B
1 Dates |Content
------------+-------
2 1/01/2018 |
3 2/01/2018 |123456
4 3/01/2018 |
5 4/01/2018 |12398
6 5/01/2018 |484
7 6/01/2018 |1538
8 7/01/2018 |
9 8/01/2018 |
10 9/01/2018 |
11 10/01/2018 |14648
12 11/01/2018 |
13 12/01/2018 |145615
14 13/01/2018 |
And with the date range in cells D2 and E2:
Date Start Date End
2/01/2018 7/01/2018
This formula returns the count:
=COUNTIFS(A:A,">="&D2,A:A,"<="&E2,B:B,">0")
This will depend on whether your numbers in Column B are formatted as text or number. If they are formatted as numbers, the above formula will work. If they are formatted as text, replace the last section ">0" with "*".
This formula adds the conditional part of your question:
=IF(COUNTIFS(A:A,">="&D2,A:A,"<="&E2,B:B,">0")=0,"",COUNTIFS(A:A,">="&D2,A:A,"<="&E2,B:B,">0"))
(If the formula returns 0, show blank)

i want to have a single column containing different values for each month

I have created a table in excel for keeping the leave records of staff. I created a scroll bar to scroll to a different month. I have added an extra column named "leave this month" which shows how many days a person has taken leave. but when I scroll to a different month (for example from January to February) the column's data stays the same. I want it to have different data for different months. for example for January it is 3 days, for February it is 4 days and... I want different values in the same cell for different months.(when I scroll to a different month the value should change) do you guys know how to do that?
screenshot
Sub showcalendar()
LeaveTracker.Columns("C:NJ").Hidden = True
LeaveTracker.Range(Columns(Range("B3").Value * 31 - 28),Columns(Range("B3").Value * 31 + 2)).Hidden = False
End Sub
Here is the approach I would use:
Define a spreadsheet with 31 X 12 columns (each group of 31 columns would represent a month, even for those cases when the month has 28/29/30 days); this spreadsheet will be use as the storage of the raw data (i.e. presence/absence of a person each day of the year),
A second spreadsheet to be use for display will have the cells linked to the first one with an horizontal offset (to the right) to be calculated as 31 * (month_number - 1); as such, when looking at the information of March, the offset would be 62 columns to the right.
Your scrollbar would run from 1 to 12 and set the value of the month (which would then be used to calculate the offset.
In this way, you don't need to copy-paste anything and, instead, you have a sliding "window" that runs right and left over your raw data sheet.
Hoe this description is clear.
So you basically have 365 columns for each day of the year. On row 4(or wherever suitable) add the month number i.e. for the first 31 columns, cells will have 01 in row4. For the next 28 columns cells in row 4 will have 02 and so on.
then in NK8, the formula to be entered should be
SUMIF($C$4:$NJ$4,$B$3,C8:NJ8)
which you can drag down for each person. B3 ahs the current month number you are viewing. The formula basically sums only those cells whose corresponding cell in row4 matches the month number in B3.
Here is a Google Sheet example.

Excel - SUM Columns IF column header is EQUAL to while another column header is EQUAL to BUT value is not 0

I have a table like this:
January February March Year to Date
Actual | Target Actual | Target Actual | Target Actual | Target
100 | 100 50 | 100 0 | 100 150 | 200
What I basically want to achieve is for Year to Date to SUM Target if Actual of each month is greater than zero (0).
Can this be achieved via Excel Formulas?
=SUMPRODUCT(B3:G3,((A3:F3)>0)*1,(B2:G2="Target")*1)
I am assuming that you can use column to the left of your data. If you can't just skip January in the sumproduct and add it with a simple IF.
Aaa +1 to this would be easier if you could re-arrange data.
The SUMIF function is helpful here.
Are you able to use an additional row? If not, is your Target always 100?
Assuming yes to one of these, the below will work. Highlighted cells have highlighted equations.
To calculate YTD Target: Green uses extra row 4, orange assumes target is always the same (100)
NB: the empty column A is so that the same equation canbe used in all cells on row 4. You can get rid of it and the equation in B4 without anything messing up.

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

Sum values in a column based on date

I have written this function that will give me a monthly sum for two columns: one has the date of each order, one has the cost of each order.
=SUMIF($C$1:$C$1000,">="&DATE(2010,6,1),$D$1:$D$1000)-SUMIF($C$1:$C$1000,">="&DATE(2010,7,1),$D$1:$D$1000)
Using data like this:
8/16/10 17:00 7.99
8/16/10 14:25 7.99
8/15/10 22:42 7.99
I end up with a table like this:
May 998
June 968.28
July 1239.76
August 514.96
However, now I would like to do daily sums and using my way I have to hand edit each row.
How can I do this better in Excel?
Use a column to let each date be shown as month number; another column for day number:
A B C D
----- ----- ----------- --------
1 8 6 8/6/2010 12.70
2 8 7 8/7/2010 10.50
3 8 7 8/7/2010 7.10
4 8 9 8/9/2010 10.50
5 8 10 8/10/2010 15.00
The formula for A1 is =Month(C1)
The formula for B1 is =Day(C1)
For Month sums, put the month number next to each month:
E F G
----- ----- -------------
1 7 July $1,000,010
2 8 Aug $1,200,300
The formula for G1 is =SumIf($A$1:$A$100, E1, $D$1:$D$100). This is a portable formula; just copy it down.
Total for the day will be be a bit more complicated, but you can probably see how to do it.
Use pivot tables, it will definitely save you time. If you are using excel 2007+ use tables (structured references) to keep your table dynamic. However if you insist on using functions, go with Smandoli's suggestion. Again, if you are on 2007+ use SUMIFS, it's faster compared to SUMIF.
Following up on Niketya's answer, there's a good explanation of Pivot Tables here:
http://peltiertech.com/WordPress/grouping-by-date-in-a-pivot-table/
For Excel 2007 you'd create the Pivot Table, make your Date column a Row Label, your Amount column a value. You'd then right click on one of the row labels (ie a date), right click and select Group. You'd then get the option to group by day, month, etc.
Personally that's the way I'd go.
If you prefer formulae, Smandoli's answer would get you most of the way there. To be able to use Sumif by day, you'd add a column with a formula like:
=DATE(YEAR(C1), MONTH(C1), DAY(C1))
where column C contains your datetimes.
You can then use this in your sumif.
Add a column to your existing data to get rid of the hour:minute:second time stamp on each row:
=DATE(YEAR(A1), MONTH(A1), DAY(A1))
Extend this down the length of your data. Even easier: quit collecting the hh:mm:ss data if you don't need it. Assuming your date/time was in column A, and your value was in column B, you'd put the above formula in column C, and auto-extend it for all your data.
Now, in another column (let's say E), create a series of dates corresponding to each day of the specific month you're interested in. Just type the first date, (for example, 10/7/2016 in E1), and auto-extend. Then, in the cell next to the first date, F1, enter:
=SUMIF(C:C, E1, B:B )
autoextend the formula to cover every date in the month, and you're done. Begin at 1/1/2016, and auto-extend for the whole year if you like.
If the second row has the same pattern as the first row, you just need edit first row manually, then you position your mouse pointer to the bottom-right corner, in the mean time, press ctrl key to drag the cell down. the pattern should be copied automatically.

Resources