Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Week Nos. With Year

Hi,

 

Is it possible to create a DAX or Calculated Column to show Week Nos based from the dates shown from the screenshot?

 

I'm looking at Week Nos. (Year)

 

 

Thanks...

 

tksnota

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous 

     

    Thank you very much Kedar_Pande for your prompt reply.

     

    If you need a union table and you need to get the week number and year after union, try the following:

     

    Here's some dummy data

     

    “Table”

     

    "Table 2"

     

    Create a new table.

     

    Union Table = UNION('Table', 'Table 2')

     

    Create a column.

     

    WeekNoYear = 
    var weekNo = WEEKNUM([Client Invoice Date], 2)
    var WeekNoYear = YEAR([Client Invoice Date]) & "-" & FORMAT(weekNo, "00")
    RETURN WeekNoYear

     

    Here is the result.

     

     

    Regards,

    Nono Chen

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

3 Replies

  • new column

    WeekNoYear = 
    VAR YearNum = YEAR('YourTableName'[Client Invoice Date]) // Get the year
    VAR WeekNum = WEEKNUM('YourTableName'[Client Invoice Date], 2) // Get week number (Monday as first day of the week)
    RETURN
    YearNum & "-" & FORMAT(WeekNum, "00") // Combine year and week number

    If this helped, a Kudos 👍 or Solution mark would be great!
    Cheers,
    Kedar Pande
    www.linkedin.com/in/kedar-pande

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

       

      I forgot to add the table is a Union table. It seems like dax is not capturing this kind of table. Is this the case?

       

      How can I still get the week nos and year

       

      Regards...tksnota

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

     

    Thank you very much Kedar_Pande for your prompt reply.

     

    If you need a union table and you need to get the week number and year after union, try the following:

     

    Here's some dummy data

     

    “Table”

     

    "Table 2"

     

    Create a new table.

     

    Union Table = UNION('Table', 'Table 2')

     

    Create a column.

     

    WeekNoYear = 
    var weekNo = WEEKNUM([Client Invoice Date], 2)
    var WeekNoYear = YEAR([Client Invoice Date]) & "-" & FORMAT(weekNo, "00")
    RETURN WeekNoYear

     

    Here is the result.

     

     

    Regards,

    Nono Chen

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