Google-sheets – Formula result depending on the week of the day

google sheetsworksheet-function

I've got a bunch of cells that have formulas to display the day of the week according to the date above it. (I'm using Google Sheets by the way)

I want the cell underneath the day of the week that has been calculated, to display a number (which is the number of stylists in the salon on that day usually) on that day of the week. i.e if the cell above says 'Tues' then to display '5' and if it says Weds to display '4' and so on….

So row 1 is date, row 2 is day of the week (calculated by the date in row 1) and I want the cells in row 3 to display the number of my wishing dependant on the day in row 2. I hope this makes sense? I tried the 'if' formula but couldn't seem to master it!

It won't let me add images, so here is the link to the master sheet:
https://docs.google.com/spreadsheets/d/1wqtMktTHcc1ldztyI_ctu58nPxRiUt6owaoOh1_KzjM/edit?usp=sharing

Best Answer

This can be solved by introducting a separate sheet, let's call it 'Weekdays':

| Weekday | Number of stylists Site 1 | Number of stylists Site 2 | Number of stylists Site 3 |
|       1 |                         0 |                         0 |                         0 |
|       2 |                         0 |                         0 |                         0 |
|       3 |                         5 |                         3 |                         5 |
|       4 |                         4 |                         4 |                         4 |
...

The first column is the weekday (0 is Sunday, 1 is Monday, etc), the next columns are the number of stylists available on that weekday, on the different sites.

Having this table, I can use a formula to match a weekday + a site with a number of stylists, from the main sheet. The following formula is for Tuesdays on Site 1:

=VLOOKUP(B$2, Weekdays!$A$2:$D$8,2)

The VLOOKUP function (check out its documentation) takes the value from B2 (Tue, which translates to 2), and matches it against the first column in the Weekdays sheet. When it finds a matching row, it returns the 2nd column - which is the Number of stylists Site 1.

Thus, the formula can be dragged across the entire row for Site 1, and it will adjust automatically.

For the other sites, you need to modify the last parameter of the formula. For Site 2, replace 2 with 3: =VLOOKUP(B$2, Weekdays!$A$2:$D$8,3), and for Site 3, replace with 4: =VLOOKUP(B$2, Weekdays!$A$2:$D$8,4)

I have set up an example spreadsheet to demonstrate this, feel free to copy it.