Solved

Assign Running Count to Period in Date Table

Posted on 2012-03-28
2
580 Views
Last Modified: 2012-06-21
I have a date table that I need to assign a running count on the "Fiscal_Year_And_Period" column in order to do look back calculations like last 13 periods average, last 6 periods average, last 3 period average, and current period within the same query. I know i can use a CASE expression to do the calcs if a period is within 13 periods of the current period, but I run into problems when those periods extend into the prior year. I have attached a spreadsheet showing the table I have to work with and highlighted in yellow the column I need created (want to use a CTE if possible). Please let me know if furthur clarification is needed.
Calendar.xlsx
0
Comment
Question by:nirajkrishna
2 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 37780306
You can get your value as follows: year*13+period -2008*13
0
 

Author Closing Comment

by:nirajkrishna
ID: 37780324
Now that is one way I never thought of solving it. Very nice!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
I have a large data set and a SSIS package. How can I load this file in multi threading?
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question