Forum Discussion
Customize Week Number (Week starting from Saturday)
- 2 years ago
Hi mukeshved80 - Hope you have a date table created at your end, if Not,
DateTable1 =ADDCOLUMNS (CALENDAR ( DATE ( 2022, 1, 1 ), DATE ( 2024, 12, 31 ) ),-- dates considering from 2022 to 2024"Year", YEAR ( [Date] ),"Month", MONTH ( [Date] ),"Day", DAY ( [Date] ),"Weekday", WEEKDAY ( [Date], 2 ), -- Returns 1 for Monday and 7 for Sunday"WeekStart", [Date] - WEEKDAY ( [Date], 2 ) + 6 -- Calculate the previous Saturday)Add a calculated column in your date table to determine the week number starting from Saturday.WeekNumber =
VAR CurrentDate = [Date]
VAR PreviousSaturday = CurrentDate - WEEKDAY(CurrentDate, 1) + 7
RETURN
WEEKNUM(PreviousSaturday, 1)another new columnWeekStartDate =
[Date] - WEEKDAY([Date], 1) + 7Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!! - Anonymous2 years ago
Hi mukeshved80
Thanks for the reply from rajendraongole1 . Here I have another idea in mind, and I would like to share it for reference.
My sample:
Create several calculated columns as follow
WeekNum = WEEKNUM([Date], 16)Week Start Date = [Date] - WEEKDAY([Date], 3) - 2Week End Date = [Week Start Date] + 6Output:
For a detailed description of the formulas used, see the following documentation:
WEEKNUM function (DAX) - DAX | Microsoft Learn
WEEKDAY function (DAX) - DAX | Microsoft Learn
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi mukeshved80
Thanks for the reply from rajendraongole1 . Here I have another idea in mind, and I would like to share it for reference.
My sample:
Create several calculated columns as follow
WeekNum = WEEKNUM([Date], 16)Week Start Date = [Date] - WEEKDAY([Date], 3) - 2Week End Date = [Week Start Date] + 6
Output:
For a detailed description of the formulas used, see the following documentation:
WEEKNUM function (DAX) - DAX | Microsoft Learn
WEEKDAY function (DAX) - DAX | Microsoft Learn
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.