How to get my graph in excel to only start on Sunday - excel

I currently have a spreadsheet that has hourly demand data for an entire year. There are monthly tabs, and within each of these is weekly data. I type in the number of the week I want to view and the column only shows data for that week. I need to find a way to get make a line graph that always starts at day number 1 (Sunday), regardless of when the week starts relative to the first day of the month. For example, week 1 for some months begins with day 6 (Friday) of the week. I want to have a graph that starts at day 6, with nothing before, and has week 2 show a full week's worth of data. The last week of the month would likely cut off before the full seven days.
tl;dr: I need a graph that only starts on Sundays.

Following the scheme:
Add the formulas:
E4 -> =WEEKDAY(A4)
E5 -> =ROW(A4)+(7-E4)
G5 -> =INDEX($A$1:$A$17;$E$5+ROW(I1)-1) ' Autocomplete
H5 -> =INDEX($B$1:$B$17;$E$5+ROW(I1)-1) ' Autocomplete
Graph Source -> =G$4:$H$11
The formulas check the first day of the table (A4), find the weekday (E4), find Sunday (E5) and generate the portion of the table in G4:H11. Only one week ...
In the same way you can add week or check the end of the mounth.

Related

Power BI: How to Group by 7 Days Bin for Bar Chart to start from Monday instead of Sunday?

I'm trying to create a barchart showing counts of events with Month View drilling down to Week and to days. I have created new groups, such as column "Month" by grouping 1 month in a bin and column "Week" by group 7 days in a bin. I noticed that when I drill down to week, it always starts on a Sunday. My client wanted to be on Monday. I've tried adding a new column "Week2" with "WeeK" dates + 1. The time axis does shows the date shifted by 1 but the data under that week still starts on Sunday. Attached is a screenshot of my barchart with group by week on Date.
Is it possible to change the Weekly Bar chart to start on Monday instead of Sunday for the drill down?
I can see two possible solution to your problem:
You could quickly create a small table to link to the day of the week you currently have on your table. Then on this table which would have the seven vaules for each day of the week you add a column with your prefered ordering (such as monday first) and then use the "Sort by column" option on the column tools in the top ribbon.
You could use a time dimension table, such as the one found here, you can specify in the script when the week starts, and you can remove all the columns you won't use.
I can't test your exact scenario at the moment, I hope one of these solution may work for you

Week number of a quarter

I'm trying to get the week number of a given quarter based on the date.
I currently have this formula
=1+(WEEKNUM(EDATE(Y4,-1)))-(WEEKNUM(DATE(YEAR(EDATE(Y4,-1)),
LOOKUP(MONTH(EDATE(Y4,-1)),{1,4,7,10}),1)))
But for January, it should be giving me 1 but it's giving me 10. Any suggestions?
How do you expect this to work at the start and end of the quarter? Default WEEKNUM function starts week 1 on the 1st of January every year and week 2 starts on the next Sunday after 1st January.
Assuming your quarter week numbers should work the same way, i.e. week 1 starts on the 1st of Jan/Apr/Jul/Oct and week 2 starts on the next Sunday then that's actually equivalent to counting Sundays since 6 days back into the previous quarter.
You can do that using NETWORKDAYS.INTL function, i.e. with this formula:
=NETWORKDAYS.INTL(EOMONTH(Y4,MOD(1-MONTH(Y4),-3)-1)-5,Y4,"1111110")
format result as number with no decimal places
NETWORKDAYS.INTL function is available in Excel 2010 and later versions - for older versions of Excel you can get the same results with this formula:
=INT((13-WEEKDAY(Y4)+Y4-EOMONTH(Y4,MOD(1-MONTH(Y4),-3)-1))/7)
(Expanded from comment)
when you choose a date in January, it's going back to December. 12 in your lookup array gives 10 as the result. Perhaps instead of EDATE, you should use EOMONTH(Y4,-1)+1, so you look at the 1st of the current month for your calculation
=1+(WEEKNUM(EOMONTH(Y4,-1)+1))-(WEEKNUM(DATE(YEAR(EOMONTH(Y4,-1)+1), LOOKUP(MONTH(EOMONTH(Y4,-1)+1),{1,4,7,10}),1)))
This is fairly interesting, since it changes with the year, and changes with what day of the week is the "start" of the week. So if a quarter starts on Saturday, and the week starts on a Saturday, the entire week is week 1. However, if it starts on a Sunday, week 1 is only one day long, and week 2 starts on Sunday.
The first question we have is, what day is it?
=DayCheck
Additionally, I'm going to call the start of each quarter the following:
Q1Start = Date(Year(DayCheck),1,1)
Q2Start = Date(Year(DayCheck),4,1)
Q3Start = Date(Year(DayCheck),7,1)
Q4Start = Date(Year(DayCheck),10,1)
The next question is, what's the first day of the week? We have some control over this with the Weekday function. For the sake of keeping it simple, Sunday is the start of the week.
Ok, that's our day. Next, what quarter is it?
`Quarter=ROUNDDOWN(MONTH(O16)/4,0)+1`
This gives us 1 for Q1, 2 for Q2, etc.
What day of the week is it now?
=WEEKDAY(DayCheck,1)
Ok, and now, what week are we on?
=WEEKNUM(DayCheck,1)
I'm going to put it together in a not very elegant fashion. I'm sure there's a better way out there.
=(Quarter=1)*((Weeknum(DayCheck)-WeekNum(Q1Start)+1)+(Quarter=2)*((Weeknum(DayCheck)-WeekNum(Q2Start)+1)+(Quarter=3)*((Weeknum(DayCheck)-WeekNum(Q3Start)+1)+(Quarter=4)*((Weeknum(DayCheck)-WeekNum(Q4Start)+1)
Try this:
=CHOOSE((MOD(WEEKNUM(Y4),13)=0)+1,WEEKNUM(Y4)-(ROUNDDOWN(WEEKNUM(Y4)/13,0)*13),13)
This will get the week number of a given date within a quarter.
I used this in one of my applications so you might be able to use it too. HTH.
Note: If you use 1st day other than Sunday, then adjust the WEEKNUM formula.
Can try this as I got this as combination of 2 formula
=WEEKNUM(A1,1)-(INT((MONTH(A1)-1)/3)*13)
second part - INT((MONTH(A1)-1)/3) gives us the quarter number of previous quarter which then multiplied with 13 weeks/quarter gives us how many weeks have passed in all previous quarter before current quarter.
First part - "WEEKNUM(A1,1)" gives us the week number of current week in the year.
so by deducting all the previous weeks in previous quarters from current week number of year, we get the current week number in current quarter.

Automatically list Sundays in a month with prefixs

So I am making a rota for a group on Sunday evenings and I thought I would mess around a little to see if I could automate the listing of the dates. I eventually either made or found a solution to almost everything. The only problem I have now is that I need two cells to show the date of the Sunday with prefixes instead of one.
The table currently looks like this
Whereas I would like it to look like this
I have a link of an online Microsoft Office Excel Book here (Its editable)
Currently I am using formula such as
=DATE(YEAR($B$3), MONTH($B$3), MOD(7-DATE(YEAR($B$3), MONTH($B$3), 1)+ 1,7)+1) //For the first Sunday of the month
=DAY(DATE(YEAR($B$3), MONTH($B$3), MOD(7-DATE(YEAR($B$3), MONTH($B$3), 1)+ 1,7)+1))&VLOOKUP(DAY(DATE(YEAR($B$3), MONTH($B$3), MOD(7-DATE(YEAR($B$3), MONTH($B$3), 1)+ 1,7)+1)),$E$4:$F$12,2,TRUE) //For the first Sunday of the month with a prefix
=IF(YEAR(B4+7)>$B$3,"",B4+7) //Subsequent Sundays
=DAY(IF(YEAR(B4+7)>$B$3,"",B4+7))&VLOOKUP(DAY(IF(YEAR(B4+7)>$B$3,"",B4+7)),$E$4:$F$12,2,TRUE) //Subsequent Sundays with Prefix
I would appreciate any help in achieving this.
For a formula solution, you can do the following.
A1: The first date in any month (e.g. 1-Jun-2016)
A2: = IF(SUM(INT((EOMONTH($A$1,0)-1)/7)-INT(($A$1-2)/7))>=ROWS($1:1), TEXT($A$1-DAY($A$1)+1+7*ROWS($1:1)-WEEKDAY($A$1-DAY($A$1)),"d")&MID("thstndrdthththththth",1+2*(MOD(TEXT($A$1-DAY($A$1)+1+7*ROWS($1:1)-WEEKDAY($A$1-DAY($A$1)),"d"),10)*(ABS(MOD(TEXT($A$1-DAY($A$1)+1+7*ROWS($1:1)-WEEKDAY($A$1-DAY($A$1)),"d"),100)-12)>1)),2),"")
and fill down to A6. It will auto adjust for months with four vs five Sundays.
The first Sunday in the month is computed by:
=A1-DAY(A1)+1+7*ROWS($1:1)-WEEKDAY(A1-DAY(A1))
The ROWS($1:1) part is used to increment the date by 7 for the subsequent Sundays.
The number of Sundays in the month, used to determine whether to blank line five, is computed by:
=SUM(INT((EOMONTH($A$1,0)-1)/7)-INT(($A$1-2)/7))
The rest of the formula is to compute the proper suffix for the date.

COUNTIF only if header of column contains specific text

I am trying to write a function in excel (without using vba/macros if possible), to count the number of remaining work days for each employee for the month, from the first of the month to a date I enter into A1. The problem is, the scheduling file I use starts on a Monday every time, so if the month begins on a Friday, there are 4 days from the previous month on the page and the same could happen at the end of the month if the month doesn't end exactly on a Saturday.
In row 6, I have the dates (formatted as 28-Sep-2015), and from rows 9 and below, I have employee names and whether or not they're scheduled to work on the days directly above in row 6. I'm looking to count the number of times the word "WORKING" appears in the row for each given employee, but only to count it if the header in row 6 contains "Sep". I don't want to count any times "WORKING" appears if it comes from the past month or the upcoming month. (Also, no one works Sundays, so Sundays are skipped.)
I'll try to show an example of set up here.. hopefully it can help:
A1: 28-Sep-2015
A6-H6: Employee, 28-Sep-2015, 29-Sep-2015,30-Sep-2015, 1-Oct-2016, 2-Oct-2016, 3-Oct-2016
A9-H9: George, WORKING, OFF, WORKING, WORKING, WORKING, WORKING
So for this small example, the result should only be 2 working days, since George only works twice from 28 Sep to the end of the month.
I've been searching for how to do this for a few days now, but nothing seems to work when I try it. Please help!
If you are using 2007 and later than use this:
=COUNTIFS($A$6:$G$6,"<="&EOMONTH($A$1,0),$A$6:$G$6,">="&DATE(YEAR($A$1),MONTH($A$1),1),$A9:$G9,"=WORKING")

Lookup formula to subtract last input data point

I am trying to write a formula that will subtract my current value from my last data point. I run a production report and over the weekends we do not produce any product. I would like the value typically from a Friday be used for calculating the change in production for Monday.
I have an input page for all the data and then a calculation page for the reports.
(Input page)
Thursday 1000
Friday 5000
Saturday "blank"
Sunday "blank"
Monday 2000
Ideally the output page would look something like this:
(output)
Friday 4000
Saturday "blank"
Sunday "blank"
Monday -3000
Having the last inputted data (being the 5000 value from Friday) subtracted from the Monday value of 2000.
Please try:
=IF(LEFT(A2,1)="S","",Sheet4!B3-INDEX(Sheet4!B:B,MATCH(1E+100,Sheet4!B$1:B2)))
with adjustment of cell references to suit.
My idea was:
=IF(B2=0,"Nonproductive",IF(B1<>0,B2-B1,B2-OFFSET(B2,-(COUNTIF(OFFSET(C2,-3,0,3),"nonproductive")+1),0)))
Imagine you've got your days in column A, and production in column B.
Copy and paste this from cell C2 onwards.
What this does, is first test if there was any production on a given day, if there was 0 production, or in your above example, "blank", then it will give the value "nonproductive". If there was production on that day, it will test if the day prior had any production, if it did, it will simply deduct yesterdays from today. If the day prior had no production, it will count the number of times that "nonproductive" has occurred in the 3 days prior and add that to the number of days in the past it looks.
On a long weekend, it would count 3 nonproductives, so it would compare Monday to Thursday.
Monday - (1 (default offset for the day prior) + 3 (due to nonproductives)
Monday - 4 = Thursday.
Notes:
This will not work for the first 2 rows because the offset will be trying to find cells that don't exist. Even if
The only problems arise when a break greater than 3 days happens, or you have a day off, then a day on, then a day off, then a day on, such as a Tuesday bank holiday, this is because there are 2 "nonproductive" days in the 3 days prior, but we only want it to increase the offset by 1. This could be avoided through continuing a chain of "if" condition checks, but it doesn't sound as though that is required.
This will work for a 2 or 3 day weekend, and some mid-week holidays

Resources