+ Reply to Thread
Results 1 to 14 of 14

Counting weeks in years

  1. #1
    Registered User
    Join Date
    11-12-2010
    Location
    Rome; Italy
    MS-Off Ver
    Excel 2003
    Posts
    14

    Counting weeks in years

    Hi,
    I have two problems:

    1. I have the list of days and week from 2007 to October 2010 and I would like to number the weeks not in sequence ( I have now 200 weeks in total in column A and F), but for every year from 1 to 52 weeks.

    2. In the H colum I have to insert the average of the data refering to each year week ( ex. average of values of 1st week of 2007, etc) and in the I column the sum of data refering to each week ( ex. sum of values of 1st week of 2007). I'm afraid to take into account all the ( for example) number 1 weeks of all the years ( instead I just want unique values).

    Could you please help me?

    ps: this forum it's really very useful!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: Counting weeks in years

    for the first part, use the weekmum argument, with 2 as your 2nd argument
    Windows 7 using Office 2007 & 2010

    Remember your [ code ] [ /code ] tags, makes reading soooo much easier

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Counting weeks in years

    Based on your definition of week 1 ( starts Jan 1st 2007) a Pivot Tale can be of help ( see attached)
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    11-12-2010
    Location
    Rome; Italy
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Counting weeks in years

    Quote Originally Posted by scottylad2 View Post
    for the first part, use the weekmum argument, with 2 as your 2nd argument
    Thank you!

  5. #5
    Registered User
    Join Date
    11-12-2010
    Location
    Rome; Italy
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Counting weeks in years

    Quote Originally Posted by arthurbr View Post
    Based on your definition of week 1 ( starts Jan 1st 2007) a Pivot Tale can be of help ( see attached)
    yeah, I was thinking about a pivot, but I would prefer not using it ( my chief doesn't like pivot very much!)...other suggestions for the scond part?

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Counting weeks in years

    What kind of solution does your chief prefer ? There are different ways of solving the problem

  7. #7
    Registered User
    Join Date
    11-11-2010
    Location
    Lublin, Poland
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Counting weeks in years

    the best, the stablest and fastest way is a pivot tab
    there is no need in complications
    see this
    Attached Files Attached Files

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Counting weeks in years

    If you want to sum column C for dates in the week beginning with the date in G3 then try this formula in row 3 copied down

    =SUMPRODUCT((B$3:B$1000>=G3)*(B$3:B$1000<G3+7),C$3:C$1000)

    for an average you could just divide that by 7....or do you want to exclude zero/blank values?
    Audere est facere

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Counting weeks in years

    Note that if you use my suggestion for summing the week numbers are incidental, you get a sum for each 7 day period based on the start date of that week.

    WEEKNUM doesn't always give you 7 day weeks at the start/end of the year so I suggest that for consistency with the above you use ISO week numbers, which is the European norm, whereby all weeks have 7 days and week 1 starts on the first Monday on or after 29th December. To calculate the ISO week number based on a date in G3

    =INT((G3-WEEKDAY(G3,2)-DATE(YEAR(G3+4-WEEKDAY(G3,2)),1,4))/7)+2

  10. #10
    Registered User
    Join Date
    11-12-2010
    Location
    Rome; Italy
    MS-Off Ver
    Excel 2003
    Posts
    14

    Smile Re: Counting weeks in years

    Quote Originally Posted by daddylonglegs View Post
    If you want to sum column C for dates in the week beginning with the date in G3 then try this formula in row 3 copied down

    =SUMPRODUCT((B$3:B$1000>=G3)*(B$3:B$1000<G3+7),C$3:C$1000)

    for an average you could just divide that by 7....or do you want to exclude zero/blank values?
    I think this is the solution I needed! No, I don't need to exclude zero/blank values. I know that with a pivot table things would be easier, but my chief prefer to see directly formulas and functions ( I don't know why!). thank you very much to every body

    Cheers

  11. #11
    Registered User
    Join Date
    11-12-2010
    Location
    Rome; Italy
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Counting weeks in years

    Quote Originally Posted by daddylonglegs View Post
    Note that if you use my suggestion for summing the week numbers are incidental, you get a sum for each 7 day period based on the start date of that week.

    WEEKNUM doesn't always give you 7 day weeks at the start/end of the year so I suggest that for consistency with the above you use ISO week numbers, which is the European norm, whereby all weeks have 7 days and week 1 starts on the first Monday on or after 29th December. To calculate the ISO week number based on a date in G3

    =INT((G3-WEEKDAY(G3,2)-DATE(YEAR(G3+4-WEEKDAY(G3,2)),1,4))/7)+2
    thank you again!

  12. #12
    Registered User
    Join Date
    11-12-2010
    Location
    Rome; Italy
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Counting weeks in years

    Quote Originally Posted by daddylonglegs View Post
    If you want to sum column C for dates in the week beginning with the date in G3 then try this formula in row 3 copied down

    =SUMPRODUCT((B$3:B$1000>=G3)*(B$3:B$1000<G3+7),C$3:C$1000)

    for an average you could just divide that by 7....or do you want to exclude zero/blank values?
    Just to my own interest: how should the formula change to exclude blank values?

  13. #13
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Counting weeks in years

    Of course the sum would be the same even ignoring blanks or zero values.....but if you want an average then dividing the above by 7 won't do that. To ignore just blanks you could use this array formula to average column D

    =AVERAGE(IF((B$3:B$1000>=G3)*(B$3:B$1000<G3+7),D$3:D$1000))

    or to ignore blanks and zeroes

    =AVERAGE(IF((B$3:B$1000>=G3)*(B$3:B$1000<G3+7),IF(D$3:D$1000,D$3:D$1000)))

    both formulas need to be confirmed with CTRL+SHIFT+ENTER

  14. #14
    Registered User
    Join Date
    11-12-2010
    Location
    Rome; Italy
    MS-Off Ver
    Excel 2003
    Posts
    14

    Thumbs up Re: Counting weeks in years

    thank you very much!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1