Data Model - Week number based on condition

Michnia25

New Member
Joined
May 31, 2015
Messages
38
Hi, I need help to set the week number based on the condition and i will be appreciated for some support.
Basically i need to add column with week number but the challenge which i facing is that the week number for my accounting start from 6am sunday morning till 5:59 am following sunday. Is there any way to set the condition based on the time and date column to set the week number?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This is an interesting data modelling problem, and the approach depends in the detail. Do you need to do day level reporting, or only week level? If the later, the easiest approach I can think of is to add a unique WeekID (integer) to the transaction table and create a week level calendar table. Ie the first week ever would be 1, then 2….then 52 for the last week of year 1, then 53, 54…etc. join the 2 tables and go from there. What else you do depends on the detail, and id this approach works.

Also, best practice is to separate date and time into 2 columns. I recommend splitting your transactional date/time into 2 columns. You should also round the time to the highest grain you can live with. Eg, don’t load seconds if minutes will do, don’t load minutes if hours will do.
 
Upvote 0
This is an interesting data modelling problem, and the approach depends in the detail. Do you need to do day level reporting, or only week level? If the later, the easiest approach I can think of is to add a unique WeekID (integer) to the transaction table and create a week level calendar table. Ie the first week ever would be 1, then 2….then 52 for the last week of year 1, then 53, 54…etc. join the 2 tables and go from there. What else you do depends on the detail, and id this approach works.

Also, best practice is to separate date and time into 2 columns. I recommend splitting your transactional date/time into 2 columns. You should also round the time to the highest grain you can live with. Eg, don’t load seconds if minutes will do, don’t load minutes if hours will do.
Thanks for that, to be honest with you I manage to achieve the final goal by splitting the date and time column then I created 2 condition columns which are checking if the date = to Sunday and if yes check if the time is <=06:00. Based on results if statement is = to True then week number = -1 or 0.
Not the most efficient way but is working :cool:
 
Upvote 0
Solution
Simple to minus 6 hours, then use weeknum
= WEEKNUM(A1-6/24)
With A1 contains real date-time
 
Upvote 0

Forum statistics

Threads
1,223,670
Messages
6,173,724
Members
452,529
Latest member
jpaxonreyes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top