Forum Discussion

Analitika's avatar
Analitika
Post Prodigy
4 years ago
Solved

Year week in Power BI

Hello,

 

I would like to get concatenated year week in table visual in Power BI. Having column Week number. I got this result:

Seems year week is unsorted. I used this formula to for column Year week. 

Year_week = FORMAT('Date'[Date],"YYYY") & "-" &'Date'[Week Number]
Week Number = WEEKNUM('Date'[Date],1).
 
How to resolve this issue by making ascending order year_week?
 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Analitika,

    You can add a calculated column to extract the year and week number value from the date to concatenate and convert to numeric, then these values can be sorted by ASC/DESC order on your visuals.

    YearWeek =
    YEAR ( 'Table'[Date] ) * 100
        + WEEKNUM ( 'Table'[Date], 2 )

    Regards,

    Xiaoxin Sheng

2 Replies

  • Hello,

     

    I would like to ask how I can sort ascending column which is constructed from year and week. I am getting year week column but sorting is not as in normal case. For example,

    Year_week = FORMAT('Date'[Date],"YYYY") & "-" &'Date'[Week Number]
    Week Number = WEEKNUM('Date'[Date],1)
    Formulaes.
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Analitika,

      You can add a calculated column to extract the year and week number value from the date to concatenate and convert to numeric, then these values can be sorted by ASC/DESC order on your visuals.

      YearWeek =
      YEAR ( 'Table'[Date] ) * 100
          + WEEKNUM ( 'Table'[Date], 2 )

      Regards,

      Xiaoxin Sheng