Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello,
I’m working on creating a custom week column in my calendar dataset and have encountered a challenge with weeks that span across months. Here’s a detailed explanation of the issue:
When a week overlaps two months, it is currently being assigned the same week number in both months. For example:
This creates a problem in reporting because:
I would like to:
Here’s a sample dataset with the current week assignment (WKFormat) and what I want the corrected week assignment (correctedWKformat) to look like:
Year Date MonthName WeekOfYear WKFormat correctedWKformat
2023 | 20/3/2023 | March | 12 | WK12 | WK12 |
2023 | 31/3/2023 | March | 13 | WK13 | WK13 |
2023 | 1/4/2023 | April | 13 | WK13 | WK14 |
2023 | 2/4/2023 | April | 14 | WK14 | WK14 |
In this example:
Has anyone encountered a similar issue or has suggestions for how to:
I’d appreciate any input, whether it’s ideas, examples, or best practices.
Thank you for your help!
Solved! Go to Solution.
Hi @Harrisfil ,
I changed the arithmetic logic and you can check the new attachment.
New WeekStart = IF(MONTH('DimDate'[WeekStart])<>MONTH([Date]),[WeekStart]+7,[WeekStart])
New Weeknum = WEEKNUM([New WeekStart],1)
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Harrisfil ,
I made simple samples and you can check the results below:
DimDate =
ADDCOLUMNS (
'Table',
"Year", YEAR ( [Date] ),
"Month", FORMAT ( [Date], "MMMM" ),
"MonthSort", MONTH ( [Date] ),
"Day", DAY ( [Date] ),
"DayName", FORMAT ( [Date], "DDDD" ),
"WeekDay", WEEKDAY ( [Date],1 ),
"WeekStart",
[Date] - WEEKDAY ( [Date], 1 ) + 1,
"WeekEnd", [Date] - WEEKDAY([Date], 1) + 7
)
CorrectedWK = IF([WeekDay] in {5,6,7}&&MONTH([Date])>MONTH([WeekStart]),[Weeknum] +1 ,[Weeknum])
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your answer .
i tried it in a full calendar and it is not giving the desired result for allo months across years. For example 31/3/2024 -01/4/2024 it gives same week.
Thanks again for spending time on that 🙂
Hi @Harrisfil ,
I changed the arithmetic logic and you can check the new attachment.
New WeekStart = IF(MONTH('DimDate'[WeekStart])<>MONTH([Date]),[WeekStart]+7,[WeekStart])
New Weeknum = WEEKNUM([New WeekStart],1)
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Thank you very much for your effort and your time
User | Count |
---|---|
84 | |
76 | |
69 | |
48 | |
39 |
User | Count |
---|---|
111 | |
56 | |
51 | |
42 | |
41 |