Excel formula AVERAGEIFS i think - excel

I'm trying to use AVERAGEIFS not sure if that's the best but here is the issue. Reporting in the new year is a PITA, the spreadsheet has dates in column A with the corresponding value in column B in 7 day increments for example Cell A1 1/7/18 Cell B1 95%, Cell A2 1/14/18 Cell B2 100%, Cell A3 1/21/18 Cell B3 62%, this goes on for the entire year. In a different cell, say C1 id like to see the average for January, in cell C2 Feb and so on.

Simplest to add another column with month or month and year (if you have multiple years worth of data), e.g. in C1 copied down
=MONTH(A1)
....and then average for January is simply
=AVERAGEIF(C:C,1,B:B)
Repeat for other months

Assuming that you are not trying to proportion the percentage in a week that straddles January to February then this for January,
=AVERAGEIFS(B:B, A:A, ">="&DATE(2018, ROW(1:1), 1), A:A, "<"&DATE(2018, ROW(1:1)+1, 1))
Fill down for subsequent months.

Related

Use Cell info in a formula

I was wondering if it's possible to use info from a cell in creating a formula. Here's the situation;
A1 = Date (01/01/17)
A2 = Month from that date (January)
I have different worksheets in the book for every month so for January the sheet is called January.
Is it possible to create a formula where I can reference a cell in a page that corresponds to the month in A2.
So for example in A3 the formula would be =January!A1
But instead of Jan I want it to be dynamic so it would change to any month depending on what I input in previous cells.
In A2 to get the month try
=TEXT(A1,"mmmm")
and then in A3
=INDIRECT(A2&"!A1")
or you can cut out A2 altogether and use just
=INDIRECT(TEXT(A1,"mmmm")&"!A1")

View week of the calendar in Excel

I want to create a calendar in Excel with 2 sheets:
Actual monthly calendar
Display current week of the month AND cells displaying data accordingly
Task: I want to show the people who are working this week rather than the whole month.
I got the code for current week display:
=TEXT(TODAY()-WEEKDAY(TODAY(),3),"mmmm dd, yyyy")&" - "&TEXT(TODAY()-WEEKDAY(TODAY(),3)+6,"mmmm dd, yyyy")
So, this will show the current eeek starting on Monday and ending on Sunday (as I needed to display)
Now:
On sheet 2, I want to show ONLY the dates of week on the calendar based on this above calculation.
Match the week start date to a list of Mondays in a different tab, then display the name of the person on the cells below the matching date (this is VLOOKUP, HLOOKUP)
Have this automatically updated every week with correct info
Is it possible? How?
I am not a coder at all.
In a blank sheet (Sheet2):
A2 =TODAY()
A4 delta
A5 to A19 consecutive values from -7 to 7
B4 Today+delta
C4 Weeknum
D4 Weekday
E4 Key
F4 Today+delta (again)
B5 =$A$2+A5 and then replicate this formula until B19
C5 =WEEKNUM(B5)
D5 =WEEKDAY(B5)
E5 =CONCATENATE(C5,"-",D5)
F5 =B5
Now extend those formulas (B5:F5) until row 19 (B19:F19)
In another blank sheet (Sheet1)
In the firs row put your formula
A2 to G2 consecutive values from 1 to 7
A3 =CONCATENATE(WEEKNUM(TODAY()),"-",A2)
Extend that formula in the range A3:G3
A4 to G4 Weekday names from Monday to Sunday
A5 =VLOOKUP(A$3, Sheet2!$E$5:$F$19, 2, 0)
Extend that formula in the range A5:G5
Until now, you should have Sheet1 with the requirement of the week showing every day of the current week. If you need a different week, just change the value in Sheet2!A2 adding or substracting days.

Excel get the next month from the selected month in a list?

I have a dropdown box with the following listed values:
January
February
March
April
May
June
July
August
September
October
November
December
Let's say a user selects 'January from my list:
I have a cell, let's call it Cell B1 and in it i have this formula
=A1
This produces 'January' in cell B1.
However in cell C1, i need to be able to +1 to which ever month is shown in Cell B1.
So if A1 = January, then B1 also = January. But C1 needs to equal February for example.
I have tried simply doing this formula in C1:
=B1 + 1
But because i need my month to be in text rather than number, this won't work and shows #Value error.
Please can someone show me how to overcome this?
You could use:
=TEXT(DATE(YEAR(NOW()),MONTH(DATEVALUE("01-"&A1&"-"&YEAR(NOW())))+1,1),"mmmm")
Select Cell B1. In cell format, select custom format and type : mmmm
then just drag the corner of this cell (like you would do to extend a formula) over cell C1 and it will display the next month.

Excel formula for just M-F and T-S of each month

I have to build a report that has two different date columns in it; M-F of the previous month, and T-S of the previous month.
If in column A I have a list of all days from the previous month
A
1 | 8/1/2013 |
2 | 8/2/2013 |
...
31 | 8/31/2013 |
Is there a formula that could be used in columns B and C to get the necessary dates?
Well, sure, you can use this formula to avoid the blank cells in between the dates:
=IFERROR(INDEX($A$1:$A$31,SMALL(IF(MOD($A$1:$A$31,7)>1,ROW($A$1:$A$31,9^99),ROW())),"")
This formula (for Monday to Friday) needs to be called with Ctrl+Shift+Enter. After doing this for the first date, you can drag down to the bottom.
For the one with Tuesday to Saturday, it's a bit longer;
=IFERROR(INDEX($A$1:$A$31,SMALL(IF(((MOD($A$1:$A$31,7)>2)+(MOD($A$1:$A$31,7)=0))>0,ROW($A$1:$A$31),9^99),ROW())),"")
But at the same time, you have to call this function with Ctrl+Shift+Enter as otherwise, you won't be able to get the other dates (you will get #NUM! instead for the other dates).
Instead of typing the days in column A, you could do something like this:
In cell B1 is this formula (formatted as m/d/yyyy):
=TODAY()
In cell B2 is this formula (formatted as mmmm):
=DATE(YEAR(B1),MONTH(B1)-1,1)
In cell A5 is this formula (formatted as m/d/yyyy):
=IF(WEEKDAY(B2,2)<6,B2,B2+1+(WEEKDAY(B2+1,2)>5))
In cell A6 and copied down to A37 is this formula (formatted as m/d/yyyy):
=IF(NETWORKDAYS(B$2,EOMONTH(B$2,0))>COUNT(A$5:A5),A5+1+2*(WEEKDAY(A5+1,2)>5),"")
In cell B5 is this formula (formatted as m/d/yyyy):
=IF(AND(WEEKDAY(A5,2)<>{1,7}),B2,B2+1+(OR(WEEKDAY(B2+1,2)={1,7})))
Lastly, in cell B6 copied down to B37 is this formula (formatted as m/d/yyyy):
=IF(B5="","",IF(MONTH(B5+1+OR(WEEKDAY(B5+1,2)={1,7})*2)<>MONTH(B$2),"",B5+1+OR(WEEKDAY(B5+1,2)={1,7})*2))
Now the M-F and T-S dates will automatically update whenever you enter a new month. If you'd prefer to manually control it, you can just type in the date of a month in cell B1, like 8/1/2013. Then the formulas will take care of the rest and will bring in the appropriate dates from July.
You can use WORKDAY function for this:
Given that you already have 1st of the previous month in A1 put this formula in B1
=WORKDAY(A$1-1,1)
.....and this one in C1
=WORKDAY(A$1-2,1)+1
then in B2....
=IF(B1="","",IF(MONTH(WORKDAY(B1,1))=MONTH(A$1),WORKDAY(B1,1),""))
and in C2
=IF(B1="","",IF(MONTH(WORKDAY(B1-1,1)+1)=MONTH(A$1),WORKDAY(B1-1,1)+1,""))
and copy those latter two formulas down to row 23
When there are fewer than 23 MF days or TS days in the month the lowest cells will display as blanks.
If you want to exclude listed holiday dates you can also do that with WORKDAY

Sum only matched values from two columns

Hello Everyone,
Does anyone know how to sum the Hours from column B (Hours) if column A numbers matched with column E and sum by months.
Example, take February data as an example, since only 3000 & 4000 existed in both column A & column E, that's why I need to sum the hours (20+10=30) from column B by it's month below.
I also attached the example excel sheet below.
https://www.dropbox.com/s/0s51g1i8g6s6e2d/Test.xls?m
Thanks in advance. :-)
You could get complicated with customer functions but if having an extra column (potentially hidden) doesn't matter then this would work:
In cell D2 enter:
=iferror(vlookup($A2,$E$2:$E$20,1,FALSE),"x")
Drag the formula down.
Under each month you can then put:
=sumifs($B$2:$B$16,$C$2:$C$16,B$22,$D$2:$D$16,"<>x")
Drag the formula across
This assumes you can change the month format in either column C or row 22 to be the same, ie. Jan, Feb, Mar or January, February, March etc.
Written on the fly and not tested so excuse any minor errors...
Both answers posted thus far are just fine, but just as an alternative, here's what I would do. Put this formula in cell D2 and drag it down:
=IF(NOT(ISNA(VLOOKUP(A2, $E$2:$E$20, 1, FALSE))), B2, "")
Then if you make a column containing the names of the months, say from G2 to G7 you have February, March, ..., July, you can put this formula into H2 and drag it down:
=SUMIFS($D$2:$D$16, $C$2:$C$16, G2)
That should get what you want.
Put this formula in Cell D2 and drag down:
=IF(NOT(ISERROR(MATCH(A2,$E$2:$E$20,FALSE))),B2,"")
In row 22, change the month names to be the full name, OR in column C, change the month names to abbreviated 3-letter names, this is so we can make use of the SumIf function.
Then, in Cell B23, put this formula and drag it across:
=SUMIF($C$2:$C$16,B22,$D$2:$D$16)
(I put the formula in row 24 to check against the data you already had in Row 23)
Shouldn't be much harder without a helper column. Just make sure you have full month name in row 22 to match column C data then use this formula in B23 copied across
=SUMPRODUCT(SUMIFS($B2:$B16,$C2:$C16,B22,$A2:$A16,$E2:$E20))

Resources