Results 1 to 5 of 5
  1. #1
    rzrbkpk is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2025
    Posts
    1

    Last Week of Fiscal Year Where Nonsequential

    I have a query that provides the last week of a field(Fiscal Week) in Year-Week format. For example, if the current week is 202452 then the previous week is 202451. I'm currently accomplishing this with the formula Max(Fiscal Week)-1 in the query field. I've run into an issue though when the new fiscal year begins. Now if the current week is 202501, my formula returns 202500, which is not a valid week. I want it to return 202452. Not sure how to accomplish this.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    I would write my own function to do this.
    Then if 202501, one can check for 01 and make that 52 and subtract 1 from year.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    436
    also, if the field [Fiscal Week] is a Date field, you just subtract 1 week from it, eg:
    Code:
    PrevWeek: Format$([Fiscal Week]-7,"yyyy") & Format$(Format$([Fiscal Week]-7,"ww"),"00")
    Click image for larger version. 

Name:	prevweek.png 
Views:	15 
Size:	7.4 KB 
ID:	52727

  4. #4
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    566
    Depending on how often you do time series analysis... it might be worth your while to create a Calendar table. Then you can compare year over year etc. But most of the time, you'd do that in Excel and maybe use DAX (which is a PITA... once you get your model right, you can do crazy stuff with it, but DAX is not easy.)

  5. #5
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    436
    If in case your [Fiscal Week] is Numeric (as in your post #1, deducting 1 resulted in 202500,
    which is Not a Valid year/week).
    Code:
    PrevMonth: DMax("[Fiscal Week]","YourTableName","[Fiscal Week] < " & [Fiscal Week])
    Click image for larger version. 

Name:	prevweek2.png 
Views:	13 
Size:	8.3 KB 
ID:	52728

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Crosstab Fiscal Year on Year Query
    By DJF in forum Queries
    Replies: 1
    Last Post: 02-07-2017, 09:27 AM
  2. Replies: 1
    Last Post: 10-14-2015, 03:45 PM
  3. Replies: 3
    Last Post: 06-22-2015, 06:36 AM
  4. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  5. Replies: 1
    Last Post: 11-01-2013, 11:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums