{"id":24,"date":"2007-04-24T06:49:00","date_gmt":"2007-04-24T11:49:00","guid":{"rendered":"http:\/\/www.dontpapanic.com\/blog\/?p=24"},"modified":"2007-04-24T06:49:00","modified_gmt":"2007-04-24T11:49:00","slug":"group-a-list-by-week-number","status":"publish","type":"post","link":"https:\/\/www.dontpapanic.com\/blog\/?p=24","title":{"rendered":"Group A List by Week Number"},"content":{"rendered":"<div class=\"ExternalClass243165FCD371426CBD177DD3A8733803\">\n<div>\n<p>I&#8217;ve seen several requests recently for how to Group a Sharepoint list by Month.&#160; I&#8217;ve also seen several Blog posts on how to do it.&#160; But recently I saw a query about how to Group by the Week Number of the year and several responses stating that it couldn&#8217;t be done.&#160; I&#8217;ve always liked a good challenge, especially one that someone else says is IMPOSSIBLE.&#160; So I decided ot figure out how to do it.&#160; The results are below.<\/p>\n<div><u>To Group a List by Week Number do the following:<\/u><\/div>\n<div><u><\/u>&#160;<\/div>\n<ol>\n<li>Make sure the list has a column that contains the Date you wish to GroupBy.&#160; I&#8217;ll use the Start Time column of a standard Event list but you can use any Date\/Time column.&#160; You don&#8217;t need to filter out the Time portion first, it will be ignored. <\/li>\n<li>Add a Calculated column to the list called &#8216;WeekNumber&#8217; that uses the following formula:          <br \/>&#160;&#160;&#160;&#160;&#160; <font face=\"Courier New\">=INT(([Start Time]-DATE(2007,1,1))\/7)            <br \/><\/font>where [Start Time] is the date column whose week you want to group by. <\/li>\n<li>Set the data type of the Calculated Column to Number with 0 decimal places <\/li>\n<li>Create the view that you want Grouped by Week. <\/li>\n<li>SORT the view by [Start Time] and GROUPBY the [WeekNumber] column. <\/li>\n<\/ol>\n<p>You&#8217;ll get a view that looks something like this:<\/p>\n<div><a title=\"GroupBy by pstorkoh, on Flickr\" href=\"http:\/\/www.flickr.com\/photos\/7962873@N07\/471629980\/\"><img loading=\"lazy\" decoding=\"async\" alt=\"GroupBy\" src=\"http:\/\/farm1.static.flickr.com\/204\/471629980_42202f0080.jpg\" width=\"500\" height=\"164\" \/><\/a><\/div>\n<div>&#160;<\/div>\n<div>This will give you a grouped list with the week number from the first day of the year.&#160; But January 1st is rarely a Sunday or Monday.&#160; If you want to be more accurate substitute the date of the first Sunday prior to 1\/1\/2007 in place of Date(2007,1,1).&#160; This will give you the week number counting from the First partial week of the year.<\/div>\n<div>&#160;<\/div>\n<div>Of course you&#8217;ll need to redo the calculated column when January rolls around next year, but only to change the Calculated Column to point at the first day of next year.<\/div>\n<div>&#160;<\/div>\n<div>&#160;<\/div>\n<\/p><\/div>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve seen several requests recently for how to Group a Sharepoint list by Month.&#160; I&#8217;ve also seen several Blog posts on how to do it.&#160; But recently I saw a query about how to Group by the Week Number of the year and several responses stating that it couldn&#8217;t be done.&#160; I&#8217;ve always liked a &hellip; <a href=\"https:\/\/www.dontpapanic.com\/blog\/?p=24\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Group A List by Week Number<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[17,15],"class_list":["post-24","post","type-post","status-publish","format-standard","hentry","category-sharepoint-2007-admin","tag-admin","tag-sharepoint_2007"],"_links":{"self":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/24","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=24"}],"version-history":[{"count":0,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/24\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}