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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DAX Weeknum

hi everyone,

 

I want to create a measure to calculate the calendar weeks. The table looks like this:

 

yearmonthdate
2020January1
2021March18
2019July6
2021September22


I tried to aggregate the data first and then use weeknum, but it did not work.

 

Thank you in advance,

1 ACCEPTED SOLUTION
Tahreem24
Super User
Super User

@Anonymous  - I tried to generate the solution using DAX.

Step 1: Create Calcualting Column like this:

Final Date =
VAR Month = SWITCH('Date'[Month],"January",1,"Febuary",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)
RETURN DATE('Date'[Year],Month,'Date'[Day])
 
Step 2: Create another column to get the weeknum:
Week Number = WEEKNUM('Date'[Final Date])
 
I am also attaching PBIX for your reference.
Hope it may help you.
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

2 REPLIES 2
Tahreem24
Super User
Super User

@Anonymous  - I tried to generate the solution using DAX.

Step 1: Create Calcualting Column like this:

Final Date =
VAR Month = SWITCH('Date'[Month],"January",1,"Febuary",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)
RETURN DATE('Date'[Year],Month,'Date'[Day])
 
Step 2: Create another column to get the weeknum:
Week Number = WEEKNUM('Date'[Final Date])
 
I am also attaching PBIX for your reference.
Hope it may help you.
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Greg_Deckler
Community Champion
Community Champion

@Anonymous I would recommend adding a true date column in Power Query and then WEEKNUM will work:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlDSUfJKzCtNLKoEsgyVYnXAwoZAjm9iUXIGSNACKmpoCVJcmgNSaYasMji1oCQ1Nym1CMg2MlKKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [year = _t, month = _t, date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"year", type text}, {"month", type text}, {"date", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [month] & " " & [date] & ", " & [year]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type date}})
in
    #"Changed Type1"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors