Forum Discussion

DNA's avatar
DNA
Frequent Visitor
8 years ago
Solved

Need DAX Statement relating to Week Numbers

I want to create a custom column by concatenating a few fields in my table using a DAX statement

 

Year

Month Number

Week of Year

 

Let's say I have the below values for each field

 

Year = 2018

Month Number = 3

Week of Year = 12

 

What I want is a value that would look like this: 20180312, where if either month number or week of year is a single digit, there is a leading 0 in front. 

 

Any thoughts would be appreciated.

 

 

Thanks

 

  • MyDate = CONCATENATE(CONCATENATE(YEAR([Date]),FORMAT(MONTH([Date]),"0#")),FORMAT(WEEKNUM([Date]),"0#"))

    DNA 

  • Add new column with following expression

     

    Week = FORMAT(Table2[Year], "0000") & FORMAT(Table2[Month], "00") & FORMAT(Table2[Week], "00")

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion
    MyDate = CONCATENATE(CONCATENATE(YEAR([Date]),FORMAT(MONTH([Date]),"0#")),FORMAT(WEEKNUM([Date]),"0#"))

    DNA 

  • Add new column with following expression

     

    Week = FORMAT(Table2[Year], "0000") & FORMAT(Table2[Month], "00") & FORMAT(Table2[Week], "00")