Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Week count after&before New Year

Hello,

 

I am a newbie who's using Power BI for the first time, and find myself struggling over Week splitting when there is a year transition.

 

Indeed, I have a TIME table, whose columns are calculated like this: 

tere_or_0-1678289877516.png

By default, Week 1 begins the first Monday of the new year (Spanish calendar, weeks are Mon-Sun).

 

The problem is that with the DAX configuration above, week 52 is absorbed by January (which is incorrect, it should fall in December):

tere_or_1-1678290109332.png

Does anyone who if/how can Power BI set a standard formula in order to consider Week 1 the one starting on January 1st, and week 52 until 31st December?

 

Thanks a lot for any hint regarding this topic (I haven't been able to find a related tutorial). 

 

Regards,

Teresa

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello @Anonymous ,

Thanks for the advice. We found a workaround (basically filtering out January 1st 2023), but I keep the code in case the workaround has more impact than initially expected and we need to re-work on it.

Thanks a lot!

Regards,

Teresa

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous ,

I have created a new sample, please refer to my pbix file to see if it helps you.

Column =
IF (
    'Table'[month] = 1
        && 'Table'[Weeknumber] > 10,
    MINX (
        FILTER (
            'Table',
            'Table'[Yearmonthnumber] = EARLIER ( 'Table'[Yearmonthnumber] )
        ),
        'Table'[Yearweek]
    ),
    IF (
        'Table'[month] = 12
            && 'Table'[Weeknumber] <= 10,
        MAXX (
            FILTER (
                'Table',
                'Table'[Yearmonthnumber] = EARLIER ( 'Table'[Yearmonthnumber] )
            ),
            'Table'[Yearweek] + 1
        ),
        'Table'[Yearweek]
    )
)

vpollymsft_0-1678849069569.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Hello @Anonymous ,

Thanks for the advice. We found a workaround (basically filtering out January 1st 2023), but I keep the code in case the workaround has more impact than initially expected and we need to re-work on it.

Thanks a lot!

Regards,

Teresa

andhiii079845
Solution Sage
Solution Sage

Did this help?
https://dax.guide/weeknum/


WEEKNUM ( 'Date'[Date],  2 ), -- Week start on Mon

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi @andhiii079845 ,

See the answer to previous comment: 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Week-count-after-amp-before-New-Year/m-p/3119... 

Thanks very much. 

Regards, 

Teresa

FreemanZ
Super User
Super User

hi @Anonymous 

try to change all 21 to 2, in line 19 and 20 of your screenshot. It is the second argument of all WEEKNUM function.

Anonymous
Not applicable

Hi @FreemanZ ,

Thank you for the tip. Unfortunately it didn't work on this case, as it took as Week 2 the week between January 2nd - 8th (in Spain week starts on Monday). It put January 1st (2023) as week 52 by the end of Januay.

We solved it by filtering out January 1st 2023 (it is not a big deal, as it's a day with 0 results). 

Thanks a lot.

Regards, 

Teresa

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.