Show only the current Week - google-sheets

I am working with Google sheets, and the Form responses that get poured into it. I am wondering if there is a way to show the CURRENT work week? What I mean by this is a sheet that shows this Friday:
MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY
124 123 193 -- 234
344
But then the next Monday:
MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY
088 -- -- -- --
Is this possible, or is it to much for google sheets?

It's certainly possible. To begin with, I would put dates under Monday, Tuesday, etc: this simplifies subsequent computations, and is also helpful when reading the data. This would go under "Monday": it returns the Monday of the current workweek:
=today()-weekday(today())+2
Here +2 compensates for subtraction when the date is Monday (which is numbered 2). The other days of the week can be obtained by adding 1 to Monday (=A2+1), or directly by using =today()-weekday(today())+3 and so on.
Then you can pull data from the form sheet using functions such as query, filter, vlookup, ... For example, this formula returns the 3rd column from Form Responses 1 where the date is nearest to the content of A2 (current Monday)
=vlookup(A2, 'Form Responses 1'!A:A, 3)
A possible issue here is that Form Responses record both date and time, so the "nearest" record may be from 11:50pm of previous day. One way to solve this is to use filter:
=filter('Form Responses 1'!C:C, floor('Form Responses 1'!A:A) = A2)
This returns all C column entries from the form where the date in the A column matches the content of A2.

Related

count how many specific days are in a time period

I want to count say how many Mondays we have from 2022-02-01 - 2022-03-01. I found smth like this:
=SUMPRODUCT(WEEKDAY(B4:C4)=2) - B4 and C4 are the dates
But it returns 0. I assume it only checks if specific date is the specific day. Any ideas how I can do this but for a date range? So how count how many Mondays there are in February
I also found this
=NETWORKDAYS.INTL(B4;C4;"1000000")
but this returns 25
You can take advantage of the NETWORKDAYS.INTL function by using the string method to make all the days as weekend except for Monday.
The String method states:
weekends can be specified using seven 0’s and 1’s, where the first number in the set represents Monday and the last number is for Sunday. A zero means that the day is a work day, a 1 means that the day is a weekend. For example, “0000011” would mean Saturday and Sunday are weekends.
In this case since you only want to know the Mondays, the string would be "0111111" and the function would look like:
=NETWORKDAYS.INTL(StartDate,EndDate,"0111111")
I think this is right. It's counting inclusively so you would get five Mondays starting on Monday 7th Feb 2022 and ended on Monday 7th March 2022 for example.
=floor((B2-(A2+7-weekday(A2,12)))/7)+1
where A2 and B2 contain the start date end end date.
Obvs nul points for me again but for the record this could be generalised if you put the day number in C2 (e.g. 1 if you want to find Sundays, 2 for Mondays):
=floor((B2-(A2+7-weekday(A2,10+C2)))/7)+1

How to auto create a Month calendar in google sheets. Where first day of the month start in the colum of the (name)day

I want to create a calendar like in the second image. But I can not figure out how to start the first column is a monday. So I fill it by 'hand' like in the first image.
I tried to create it automatic. Starting with the first day of the month and add one day the next columns like in the second picture:
How I want it to look like:
How it is currently looking:
Google sheets example
I was solving the same problem for my bussiness, and I think I got the answer.
Your first task is to determine the first "calendar monday" of the month.
First, build the first day of the corresponding month:
[B2] =DATE(YEAR(A1); MONTH(A1); 1)
Then, get the WEEKDAY of the corresponding first day. The second argument represents what day your week starts with:
If type is 1, days are counted from Sunday and the value of Sunday is 1, therefore the value of Saturday is 7.
If type is 2, days are counted from Monday and the value of Monday is 1, therefore the value of Sunday is 7.
If type is 3, days are counted from Monday and the value of Monday is 0, therefore the value of Sunday is 6.
In my case, we count the week starting from Monday. This means when the first day of the month lands on Monday, the return value will be 0.
[C2] =WEEKDAY(B2; 3)
The number you get represents how many days you need to substract from the initial date to get the first "calendar monday" of the month:
[D2] =B2 - C2
This date is what you are looking for. The final formula:
[A3] =DATE(YEAR(A1); MONTH(A1); 1) - WEEKDAY(DATE(YEAR(A1); MONTH(A1); 1); 3)
The rest of the days, simply add 1 to each preceding date.
[A4] =A3 + 1
[A5] =A4 + 1
And so on.
Secondly, set the Number Format on the calendar cells to just show the day.
Format -> Number -> More Formats -> More Date and Time Formats.
Select just the day from the drop down.
Finally, use conditional formatting to "hide" the values that don't match the initial date
Use a custom formula for the formatting, as follows:
=MONTH(A3) <> MONTH(A1)
Apply to the calendar range. This will format dates that don't belong to the current date, so make sure to paint that white.
And that's about it. Good luck!

MODE with SUMPRODUCT formula

I am trying to find a mode of weekdays (Monday, Tuesday, etc.) within a date range by using the formula:
=ARRAYFORMULA(MODE(SUMPRODUCT(--(AgendaData!$A:$A>=A$6),--(AgendaData!$B:$B<=B$6),AgendaData!$F:$F)))
The error reads: "MODE cannot produce a result. No values occur more than once."
I think it has something to do with the F column being in text format. I want the result to show the mode of the weekday in text. I wonder what I am doing wrong here.
You can find the mode of text values by converting them to numbers, finding the mode, and converting back. It's convenient to use a three-column lookup table for this, e.g.,
Monday 1 Monday
Tuesday 2 Tuesday
Wednesday 3 Wednesday
Thursday 4 Thursday
Friday 5 Friday
Saturday 6 Saturday
Sunday 7 Sunday
Let's say this table is in columns I:K, and your data is in column F. Then the following finds its mode:
=vlookup(mode(arrayformula(iferror(vlookup(F:F, I:J, 2, false)))), J:K, 2)
Here, arrayformula(iferror(vlookup... is conversion to numeric, using the part I:J of the table, and ignoring blank cells and anything that isn't a day of week. After mode is applied, vlookup converts the number back to text using the part J:K of the table.
To check it out, you may use formula:
=filter(AgendaData!$F:$F,AgendaData!$A:$A>=A$6,AgendaData!$B:$B<=B$6)
You'll see all matching values from column F and will know exactly if some values occur more than once.

Excel Formula: weekly comparison with corresponding week of previous month

I'm trying to create a week on week comparison in Google Sheets.
The nuance is that the Comparison Week needs to dynamically populate as the corresponding week of the previous month.
So if the dataset is the first week of May, the Comparison Week would be the first week of April. Likewise, week 2 of May would be compared to week 2 of April, etc.
As an example, if A1 is 5/1/2016 and A2 is 5/7/2016, cells B1 and B2 should populate as 4/3/2016 and 4/9/2016 respectively (where Sunday is the first day of the week).
I've built the following formula which I think gets me about halfway:
=WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),MONTH(A1),1),1)+1
This formula returns the week number in the month from a given date. For example, 5/1/2016 returns the value '1' because the date occurs on the first week of the month. 5/8/2016 would return '2', etc.
Use formula below. It looks ugly, but it should work exactly as your example.
As an example, if A1 is 5/1/2016 and A2 is 5/7/2016, cells B1 and B2
should populate as 4/3/2016 and 4/9/2016 respectively (where Sunday is
the first day of the week).
=DATE(YEAR(A1),MONTH(A1)-1,DAY(A1)+IF(WEEKDAY(A1-DAY(A1)+1)=1,8,WEEKDAY(A1-DAY(A1)+1))-WEEKDAY(DATE(YEAR(A1),MONTH(A1)-1,1),1))
here is how it works
=DATE(
YEAR(A1),
MONTH(A1)-1,
return date of previous month with day calculated as follows:
DAY(A1)
start at the current date
+IF(WEEKDAY(A1-DAY(A1)+1)=1,8,WEEKDAY(A1-DAY(A1)+1))
find out what day is the first day of the current month and add its number. Only if it is Sunday (1st day of week) it needs to skip week 0 so it adds 8
-WEEKDAY(DATE(YEAR(A1),MONTH(A1)-1,1),1)
deduct number representing first day of previous month
So for example if you have 5/3/2016 it does:
(3rd day of month) + (first day of current month in Sunday, so add 8) - (first day of previous month is Friday, so it deduct 6)
3 + 8 - 6 =5 and this is day of previous month, so result is 4/5/2016

'weeknum' function

Here is what I'm trying to do:
I have three Spreadsheets.
(1) Days (holds increase in user-nr per day)
(2) Weeks (is supposed to sum up user increases so they are shown each week)
(3) Months (is supposed to sum up user increases so they are shown each month)
To give an example: if we have 10 users on Monday, 20 more on Tuesday, 15 more on Wednesday (that's when the next calendar week starts), then I want in the sheet "weeks" to see e.g. 45 users in calendar week 27 or so.
So what I try is this: =SUMIF(WEEKNUM(Days!A2:A977); A2; Days!B2:B977)
A holds the date of the day
B holds the number of users.
What happens is it does not sum up the number of the users shown in B, but only gives the number in the first cell of the weeknumber shown in A2.
What is my mistake?
The formula seems to be correct, but two things are needed.
You should embrace it in ArrayFormula()
You should use one more weeknum()
=ArrayFormula(sumif(weeknum(Days!A2:A977);weeknum(Days!A2);Days!B2:B977))

Resources