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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
ElMeSaFeR
Regular Visitor

DAX - Week Number - to start from 1st Jan

Hello!

I've used CALENDAR() in a new table and I've obtained a date column, I'd like to calculate a new column with DAX to obtain the week number ( 1 - 54 ), but with the following condition:

1) The first week of the year should be the 1st January for every year.

 

2022-04-23_221303.png

 

I've read similar posts and tried to apply and modify the DAX code to acheive that, but I haven't succeed.

 

Thanks in advance for your help

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @ElMeSaFeR ,

 

How about this:

tomfox_0-1650800560745.png

 

 

Here the DAX that was used to create the calculated column:

WeekNumber = 
ROUNDDOWN (
    ( ( RANKX ( 
        FILTER ( 
            'date', 
            'date'[Year] = EARLIER ( 'date'[Year] )
        ),
        'date'[Dates],
        , ASC
        , DENSE
    ) + 6 ) ) / 7, 0 )

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
tackytechtom
Super User
Super User

Hi @ElMeSaFeR ,

 

How about this:

tomfox_0-1650800560745.png

 

 

Here the DAX that was used to create the calculated column:

WeekNumber = 
ROUNDDOWN (
    ( ( RANKX ( 
        FILTER ( 
            'date', 
            'date'[Year] = EARLIER ( 'date'[Year] )
        ),
        'date'[Dates],
        , ASC
        , DENSE
    ) + 6 ) ) / 7, 0 )

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Excellent, Thanks alot 🙂

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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