Results 1 to 10 of 10
  1. #1
    Leex is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    4

    Grouping by consecutive months


    Batch Date CuttingsTaken
    128880 18/12/2013 17150
    128880 19/12/2013 32500
    128880 07/01/2014 1500
    128880 15/12/2014 53700
    128880 17/12/2014 975
    128880 07/01/2015 400
    128880 16/12/2015 9750
    128880 17/12/2015 3850
    128880 18/12/2015 31100
    128880 08/07/2016 31925
    128880 12/07/2016 22525
    128880 13/07/2016 41200
    128880 27/07/2017 119875
    128880 31/07/2018 77150
    128880 01/08/2018 57750

    Hello. Based on the data above could you please help me to find a way to group the data by 2+ consecutive months and sum the number of "CuttingsTaken". The reason why i need to group them is because we have two seasons: Winter (Dec-Feb) and summer (Jun-Sep) and I would like to have the totals per batch per season. I was trying to find the answers myself but with no avail. Please help me out.
    Thank you in advance.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Provide a sample of what you want based on your data.

  3. #3
    Leex is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    4
    From that data I would like to have:
    Batch____ Season____ CuttingsTaken

    128880____ winter 2014 ______51150 (18th, 19th Dec 2013 + 7th Jan 2014)
    128880____ winter 2015____ 55075
    128880____ winter 2016____ 44700
    128880____ summer 2016____ 95650
    128880____ summer 2017____ 119875
    128880____ summer 2018____ 134900

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You need to calculate fields that assign season to each record as well as extract year.

    Season: IIf(Month([Date]) BETWEEN 6 AND 8, "summer", "winter")
    Yr: Year([Date])

    Now use those fields to group/sort/filter records.


    Date is a reserved word and should not use reserved words as names for anything.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I might use a table that had a season field ("winter 2014") and start/end date fields. Then use a non-equi join to that table to get the season. My gut is that June7's method will separate "winter 2014" into 2 records since the data falls into two different years, but I could be wrong.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Good point. Will need to decide which year to assign Dec/Jan/Feb. If you want to keep Dec with the following Jan/Feb year:

    Yr: Year([Date]) + IIf(Month([Date]) = 12, 1, 0)

    Or build a table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Or

    Season: IIF(MONTH([Date]+31)<6;"Winter";"Summer") & " " & YEAR([Date]+31)

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I kept the 2 calcs separate to allow easier filter/sort by year.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Leex is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    4
    Thank you for suggestions guys. I will try this on my data set and let you know the results.
    June7 you are right, to the winter season the year assigned is the following one (e.g. period Dec 2017 - Feb 2018 is going to be winter 2018).

  10. #10
    Leex is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    4
    All working well. Many thanks for your help.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-04-2017, 01:19 AM
  2. Replies: 3
    Last Post: 02-23-2014, 02:06 PM
  3. Report Grouping - Months
    By Kirsti in forum Reports
    Replies: 2
    Last Post: 07-11-2012, 04:27 PM
  4. Grouping info for the last twelve months
    By herbc0704 in forum Queries
    Replies: 2
    Last Post: 09-14-2011, 10:30 AM
  5. Replies: 1
    Last Post: 06-09-2011, 09:15 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