Microsoft Excel - SumIF with WeekNum - excel

I want to sum the values with-in a data range, subtract value within a specific day.
I'm able to do first part - SUM but got a problem when I tried to subtract.
Formula used on "Exclude Sunday" table
F3 =SUMIFS(B3:B17,A3:A17,">="&D3,A3:A17,"<="&E3)
Help on this above formula to subtract Sundays hours.
On Sunday Only table, help to add hours of Sundays only of each months.
I tried SUMIFS with WEEKNUM, but couldn't get the result.

Weeknum() returns the number of the week, which is not useful in your scenario, since you want to evaluate the week day. That is what the Weekday() function does quite nicely. With the defaults, Weekday() returns 1 for a Sunday, 2 for Monday, and so on.
You can use Sumproduct to calculate a sum of all hours between two dates where the weekday is not Sunday like this in cell F3 of your screenshot.
=SUMPRODUCT((WEEKDAY($A$3:$A$17)<>1)*($A$3:$A$17>=$D3)*($A$3:$A$17<=$E3)*B3:B17)
Copy down.
In order to sum all Sunday hours in January, you can use Sumproduct and compare the date formatted as "mmm" with the text in cell D10, and also use a condition to calculate only dates where the weekday is Sunday (i.e. 1). Cell E10 has the formula
=SUMPRODUCT($B$3:$B$17*(TEXT($A$3:$A$17,"mmm")=$D10)*(WEEKDAY($A$3:$A$17)=1))

Related

Formula for SUMing certain months but disregard blank cells

I'm trying to total sales amount in a column for a certain month. The column with the dates will include blank cells.
I got this code to work once but when I try to change the sheet it references it just comes up with $0.
=IF(ISBLANK(eBay!$A$2:$A$3000),0,(SUMPRODUCT((MONTH(eBay!$A$2:$A$3000)=1)*eBay!$H$2:$H$3000)))
Where the Month Column is eBay!A2:A3000 and the sales column is eBay!H2:H3000.
I've also tried:
=SUMIFS:(eBay!H2:H3000, eBay!A2:A3000, (MONTH(eBay!A2:A3000)=1, eBay!A2:A3000, "<>")
I tried the Evaluate Formula for the first formula and it comes up as TRUE for ISBLANK when there are two cells with dates in them.
The second formula says the MONTH is 4 when there is a Month for January. So I changed the date from 1 to 4 and it didn't total for April either.
I thought either one of these formulas would work. What can I try next?

Excel Date table to determine next Bi-annual date from Input date

I am creating a Table in excel to help determine what the Bi-annual dates would be from an input date.
Example: If the start date of an agreement is 9/1/2017 and Ends 8/31/2018, the Bi-annual dates would be 2/28/18 and 8/31/2018. Dates of service would be 2 months before the end of the agreement period, and six months before the second service date (so 6/30/2018 and 12/31/2017 respectively).
Formula for this:
=IF(ISBLANK(O3), "",IF(EOMONTH(A1, 0)=EOMONTH(O3, -2), "BIANNUAL", IF(EOMONTH(A1, 0)=EOMONTH(O3, -8), "BIANNUAL", "")))
Where A1 refers to January, B1 would be February, and so on thru to December (L1). O3 is the Agreement End Date box, and will be static on the sheet. This formula work perfect for me.
What I am trying to get is a formula for the cells at the top that list the months (Jan-Dec). I need a formula that will put the date as 1/31/2018 for Jan, 2/28/2018 for Feb, 9/30/2017 for September (for the current year since September has not passed). The actual day needs to be the last day of the month, and if that month has passed, then the year should be for next year. I have been playing with the DATE function, but cannot get it nailed down.
What I have so far - January 2018:
=DATE(YEAR(TODAY()+365), MONTH(42766), DAY(EOMONTH(42766, 0)))
This works, but not each month will be in 2018. I need the year to change only after the month has passed.
I feel like I'm either over complicating things, or I need a way more complex formula. Please help.
In A1 place the following formula and copy right to L1 or as far as you need to go
=EOMONTH($O$2,COLUMN(A1)-1)
It will display the end of month dates starting with the starting month of the contract and increasing by 1 month for each column you move right.
In the image below, it is the same formula in row 1 and row 2. Row one I choose custom format instead of date and set the custom format to mmmm. 4 m's will give you the full month, and 3 m's will give you the 3 starting letters of the month.
I actually figured this out this morning just playing with the IF function. My goal was to have the sheet update itself without having to change the dates every time your open it. So that the file could be shared with others and all you would have to enter is the end of the contract date, and it will list out Biannual, Tri-annual, and Quarterly months (see image).
Formula:
=IF(DATE(YEAR(TODAY()), MONTH(42766), DAY(EOMONTH(42766, 0)))<TODAY(), DATE(YEAR(TODAY()+365), MONTH(42766), DAY(EOMONTH(42766, 0))), DATE(YEAR(TODAY()), MONTH(42766), DAY(EOMONTH(42766, 0))))
Where I used the serial for each month (in this case 1/31/2017, as I didn't need to worry about the year)
Results

Excel Formula: Get Year to Date Workday Count in Current Month

I need a formula that gives me the YTD workday count for each month.
For example:
If today is 8/6/2015 - the workday count should be 17 (excluding weekends)
If today is 9/3/2015- the workday count should be 18 (excluding weekend and 1 holiday)
Thanks,
This is just the native Excel function:
=NETWORKDAYS(TODAY(),DATE(YEAR(TODAY()),MONTH(TODAY()),31))
Note that you will need to choose a set of holidays to exclude from the working days function, and define that as a Name in the Formula Ribbon -> Name Manager. ie:
=NETWORKDAYS(TODAY(),DATE(YEAR(TODAY()),MONTH(TODAY()),31),CustomHolidays)
Where CustomHolidays has been defined as a name which means:
={02/14/2015;03/15/2015;...}
You need NETWORKDAYS between the first of the month, and the last of the month.
Assuming your date is in A2, first of the month is simple, A2-DAY(A2)+1. Last of the month is harder as it could be 28, 29, 30 or 31. Youy can use EOMONTH to get this though, EOMONTH(A2,0)
Put it all together
=NETWORKDAYS(A2-DAY(A2)+1,EOMONTH(A2,0))
As has been commented, you can also include holidays if you wish to exclude these.

Conditional format of date where 3 working days greater than cell value

I am trying to adapt a number of forum posts and previous stack questions like this.
Let's say I have a date Column A2, A3, A4 etc.
I want to be able to utilize the WEEKDAY function to evaluate my condition when only in a Weekday and also 3 days greater than the date in Cell A(x).
So far my attempts have failed or I have not got the results I want. Excel is not my strongest point when it comes to conditional formula formatting.
I think it may be something like:
=WEEKDAY(A$2,2) <=5 AND 'My Cell Date' > 3 Days WHERE those 3 days are weekdays.
Also if it is possible, I want it to work like:
If day 1 of 3 is Thursday, day 2 of 3 is Friday and day 3 of 3 is Monday then apply formatting.
Could anyone help me out with this one please?
Edit not from OP to copy clarification from comments:
If the today date is 3 working days greater than the cell date change to red.
Say A2 has a received date and B2 has a completed date. The completed date is my target. Is it 3 working days greater than received.
Was not quite certain of the requirement (but seem to have hit upon an acceptable solution!):
Use =NETWORKDAYS(A2,B2)>2 under Format values where this formula is true: under Use a formula to determine which cells to format in Conditional Formatting.
NETWORKDAYS
Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays.
The syntax is:
NETWORKDAYS(start_date,end_date,holidays)
Dates should be entered by using the DATE function, or as results of other formulas or functions.

How to calculate values in a column based on only weekends ( saturday and sunday) in excel?

I have a column 'day' (C6:C37) showing the day of the month and a column 'dailytotal' (F6:F37) showing the total expenditure on each day. I want to calculate total expenditure only on weekends.
How do I calculate the sum of values in 'dailytotal' when Saturday or Sunday is in column 'day'. How can I use SUMIF here for my requirement?
You can use the WEEKDAY function to determine what day a date falls on. However, there's no way to use that directly with a SUMIF formula.
Alternatively, you can use a SUMPRODUCT formula:
=SUMPRODUCT(--(WEEKDAY(C6:C37,2)>5), F6:F37)
If you HAVE to use sumif (though Michael's solution works nicely). Here is what you can do.
Add a column (I will refer to as "weekday_range") that takes the =weekday(date, 2) (and fill down column)
THEN you can use
=sumif(weekday_range, ">5", daily_total_range)
you can then hide the column that weekday_range is in if needed

Resources