Counting Formula

BrettOlbrys1

Board Regular
Joined
May 1, 2018
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Based on a week date, I want to assign a "1" to that date. The dates greater than that date, I want the value to count up by +1 and the dates less than that date, I want them to count down by -1. My file is not static though because based on when the file is opened, the numbers assigned to the static dates will move. I need a formula that will assign the numbers above the dates.


If today was 4/19
-5-4-3-2-10123456789
3/83/153/223/294/54/124/194/265/35/105/175/245/316/76/14
If today was 5/10
-8-7-6-5-4-3-2-10123456
3/83/153/223/294/54/124/194/265/35/105/175/245/316/76/14
If today was 5/24
-10-9-8-7-6-5-4-3-2-101234
3/83/153/223/294/54/124/194/265/35/105/175/245/316/76/14
 
Here is what I am doing. I run weekly activity reports of a sales team and graph the corresponding results. Currently, I manually edit the graphs and choose which weeks to show on the graph, but I want to automate the graphing by always using the latest 12 weeks of data. I plan to do this by using an INDEX MATCH formula.

I have one sheet for all of 2021 with each column having a date, such as the Monday of every week (5/3, 5/10, 5/17, etc...). This sheet is where I place all of the RAW data for every week of the year. On a separate sheet, I have a table that will be auto-populated with the last 12 weeks of data based on whenever the file is opened because it will compare the TODAY () date against the sheet with the columns of raw data.

I need the table, that I will be using to graph, to auto-populate with whatever the last 12 weeks are. My plan was to place a "1", "2", "3", etc... in 12 corresponding columns. Based on the TODAY () date, the sheet will look to the raw data DATE sheet for each week and then assign the "1", "2", "3", etc... to those raw data columns. I will then use the INDEX MATCH to pull the 12 weeks of data into my graphing table.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
My plan was to place a "1", "2", "3", etc... in 12 corresponding columns. Based on the TODAY () date,
So my suggestion in post #9 doesn't do what you want? If not, can you explain exactly what should be different with those results given today's date of 11 may?
 
Upvote 0
Here is what I am doing. I run weekly activity reports of a sales team and graph the corresponding results. Currently, I manually edit the graphs and choose which weeks to show on the graph, but I want to automate the graphing by always using the latest 12 weeks of data. I plan to do this by using an INDEX MATCH formula.
@BrettOlbrys1 you mention wanting latest 12 weeks, but your original post here shows 15 weeks of results. ???
 
Upvote 0
your original post here shows 15 weeks of results. ???
I suspect that might be an example snippet of ..
I have one sheet for all of 2021 with each column having a date, such as the Monday of every week (5/3, 5/10, 5/17, etc...). This sheet is where I place all of the RAW data for every week of the year.
.. from which the OP is trying to extract the correct 12 weeks for the graph.

@BrettOlbrys1
Thanks for updating your profile. (y)
Since you have 365 you might be going to too much trouble to insert these numbers then INDEX/MATCH to try to extract your 12 weeks of interest. I don't really know exactly what you have on the raw data sheet or what parts of it to extract but here is a small example to show how the data may possibly be extracted with a single formula in a single cell.

Here is my raw data sheet with some dummy data and dates (mine are in d/m/y format) for a whole year. I have hidden some columns to keep this sheet smallish for the forum

BrettOlbrys1.xlsm
ABCRSTUVWXYZAAABACADAEAYAZ
25/01/2112/01/2119/01/214/05/2111/05/2118/05/2125/05/211/06/218/06/2115/06/2122/06/2129/06/216/07/2113/07/2120/07/2127/07/213/08/2121/12/2128/12/21
3data 1data 2data 3data 18data 19data 20data 21data 22data 23data 24data 25data 26data 27data 28data 29data 30data 31data 51data 52
4other 1other 2other 3other 18other 19other 20other 21other 22other 23other 24other 25other 26other 27other 28other 29other 30other 31other 51other 52
Raw data


Now, suppose that we want 12 columns extracted starting at today's date (or if today's date is not in the raw sheet, starting at the most recent date before today) we can do that with this formula entered into A1 (or any cell you want) below.

BrettOlbrys1.xlsm
ABCDEFGHIJKLM
111/05/2118/05/2125/05/211/06/218/06/2115/06/2122/06/2129/06/216/07/2113/07/2120/07/2127/07/21
2data 19data 20data 21data 22data 23data 24data 25data 26data 27data 28data 29data 30
3other 19other 20other 21other 22other 23other 24other 25other 26other 27other 28other 29other 30
4
12 weeks
Cell Formulas
RangeFormula
A1:L3A1=FILTER('Raw data'!A2:AZ4,('Raw data'!A2:AZ2>TODAY()-7)*('Raw data'!A2:AZ2<=TODAY()+77),"")
Dynamic array formulas.
 
Upvote 0
Thanks guys. I am going to use what you have provided and see how each proposed solution works and report back. Is it possible for me to attach a spreadsheet that I have formatted versus only attaching these embedded tables above because I cannot install anything since this is a company laptop and they have it locked down?
 
Upvote 0
Is it possible for me to attach a spreadsheet that I have formatted versus only attaching these embedded tables ...
No, you cannot attach an actual workbook. The other alternatives are

- copy/paste directly but that lacks most formatting, formulas etc. eg

5/01/2112/01/2119/01/21
data 1data 2data 3
other 1other 2other 3

- upload a small sample dummy file to DropBox, OneDrive etc and provide a shared link here, though some forum helpers choose not to download such files or, like you, are prevented from doing so by workplace restrictions.
 
Upvote 0
OK, so let me try to be a little more clear. Here is an actual set of data that I have in my worksheet:

1/41/111/181/252/12/82/152/223/13/83/153/223/294/54/124/194/265/35/10
58604958545948536161515342425046473430

Each date shows the amt. of activity for that week and I always graph the latest 12 weeks of data. For example, this week I would graph 2/22 through 5/10 because those are the most recent 12 weeks of data. Last week I would have graphed 2/15 through 5/3 and the week before I would have graphed 2/8 through 4/26, you get the idea.

When I produce my report, I manually edit the graph to select the latest 12 weeks of data, but I want to automate this function so the graph will always display the latest 12 weeks of data. My working concept was to have the raw data table (like the above) and then have a second table where only 12 data points could be written (see below). Each of the 12 columns will always have an assigned value (1-12). In row 2, the sheet would place the latest 12 DATES from the above table and in row 3, the sheet would place that week's corresponding VALUE from the above table.

Where I am getting stuck is how to identify the latest 12 weeks of data as that will change based on when I run the report. I thought I could write a formula that would assign a value (1, 2, 3 ,4, etc.) to each column in the raw data table (above) based on the dates listed for each column and based on when the report is run. Based on those values (1 - 12), I could simply do an INDEX MATCH and then populate the graphing table below with the columns that have the values of 1 - 12.

Does this make more sense?

ABCDEFGHIJKL
1123456789101112
2
3
 
Upvote 0
@Peter_SSs

Peter, it appears your suggestion in post #9 will work, but I have a couple of questions to understand what you did and learn how to use this formula:

1) it is taking today's date and providing the next 11 columns of data, but I want it to provide the previous 11 columns of data. How do I modify the formula to do this?
2) What does the +77 value represent and why that number?

Thanks,

Brett
 
Upvote 0
1) it is taking today's date and providing the next 11 columns of data, but I want it to provide the previous 11 columns of data. How do I modify the formula to do this?
2) What does the +77 value represent and why that number?
Let's try again. It is now 12 May here.

BTW, you never answered my question:
Your dates are all one week apart and all of your examples have "today's date" as one of the values in the row. What should happen if today's date is not actually in the list?

Here is (part of) my new Raw data sheet

BrettOlbrys1.xlsm
ABCDEFGHIJKLMNOPQRSTU
26/01/2113/01/2120/01/2127/01/213/02/2110/02/2117/02/2124/02/213/03/2110/03/2117/03/2124/03/2131/03/217/04/2114/04/2121/04/2128/04/215/05/2112/05/2119/05/2126/05/21
3data 1data 2data 3data 4data 5data 6data 7data 8data 9data 10data 11data 12data 13data 14data 15data 16data 17data 18data 19data 20data 21
4other 1other 2other 3other 4other 5other 6other 7other 8other 9other 10other 11other 12other 13other 14other 15other 16other 17other 18other 19other 20other 21
Raw data
Cell Formulas
RangeFormula
B2:U2B2=A2+7



The -84 in the formula below is the number of days to allow for 12 weeks of results.

BrettOlbrys1.xlsm
ABCDEFGHIJKLM
124/02/213/03/2110/03/2117/03/2124/03/2131/03/217/04/2114/04/2121/04/2128/04/215/05/2112/05/21
2data 8data 9data 10data 11data 12data 13data 14data 15data 16data 17data 18data 19
3other 8other 9other 10other 11other 12other 13other 14other 15other 16other 17other 18other 19
4
12 weeks
Cell Formulas
RangeFormula
A1:L3A1=FILTER('Raw data'!A2:AZ4,('Raw data'!A2:AZ2<=TODAY())*('Raw data'!A2:AZ2>TODAY()-84),"")
Dynamic array formulas.
 
Upvote 0
@Peter_SSs

Peter, it appears your suggestion in post #9 will work, but I have a couple of questions to understand what you did and learn how to use this formula:

1) it is taking today's date and providing the next 11 columns of data, but I want it to provide the previous 11 columns of data. How do I modify the formula to do this?
11 weeks previous of today's date, today's date, 11 weeks after today's date:

The following would set '0' to the current date. If you still want the current date to reflect a '1' value then change the formula to '7 + 1'

Book1
ABCDEFGHIJKLMNOPQRSTUVW
1-11-10-9-8-7-6-5-4-3-2-101234567891011
223-Feb-212-Mar-219-Mar-2116-Mar-2123-Mar-2130-Mar-216-Apr-2113-Apr-2120-Apr-2127-Apr-214-May-2111-May-2118-May-2125-May-211-Jun-218-Jun-2115-Jun-2122-Jun-2129-Jun-216-Jul-2113-Jul-2120-Jul-2127-Jul-21
3
4
Sheet1
Cell Formulas
RangeFormula
A1:W1A1=(A2-TODAY())/7
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,867
Members
449,053
Latest member
Mesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top