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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
afk
Advocate II
Advocate II

Week number with 2 digits

Hi,

 

The weeknum formula returns the weeks 1 to 9 as single digits. Is there a way to display these as 2 digits, e.g. 01, 02....09?

 

Thanks!

1 ACCEPTED SOLUTION
afk
Advocate II
Advocate II

Looks like I've managed to solve this myself Smiley Happy

 

I used the DAX Formula " weeknumber = FORMAT(WEEKNUM([date],1),"00")  "

 

If anyone has any other better solutions, please feel free to contribute.

View solution in original post

5 REPLIES 5
afajardo
New Member

If you are doing it in Power Query - M Code then this is what I would use:

 

if Date.WeekOfYear([DATE]) < 10 then "0" & Number.ToText(Date.WeekOfYear([DATE])) else Number.ToText(Date.WeekOfYear([DATE]))

afk
Advocate II
Advocate II

Looks like I've managed to solve this myself Smiley Happy

 

I used the DAX Formula " weeknumber = FORMAT(WEEKNUM([date],1),"00")  "

 

If anyone has any other better solutions, please feel free to contribute.

Anonymous
Not applicable

If your week numbers are stored as whole numbers, then:

format(if(WEEKNUM([date]<10,CONCATENATE(0,WEEKNUM([date]),WEEKNUM([date]),00)

 

that is,

 

format (<value>, <format_string>) where  

<value> = if(WEEKNUM([date]<10,CONCATENATE(0,WEEKNUM([date]),WEEKNUM([date]

and

<format_string> = 00


@afk wrote:

Looks like I've managed to solve this myself Smiley Happy

 

I used the DAX Formula " weeknumber = FORMAT(WEEKNUM([date],1),"00")  "

 

If anyone has any other better solutions, please feel free to contribute.


 

zgiersky
Frequent Visitor

You could go with additional custom column (based on your formula):

 

 

date = FORMAT(DATE(LEFT([Year-Month],4),RIGHT([Year-Month],2),1),"yyyy-mm")

hi, @afk

 

This is correct.

But you could do this directly in POWER QUERY, with a similar formula, removing the calculation from the tip.
Or use a CALENDAR table for this and standardize the dates of your dashboard.

 

Please try and test using it. And please mark the right reply as answer if your issue has been resolved, otherwise, please feel free to ask if you have any other issue.

Best Regards,
Rfranca

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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