In Power BI, if you are creating a year-week sales report, then you will encounter a most common issue. i.e Power BI by default returns single-digit week number/month number.

Default Sorting in Power BI:

But the desired results are:

  • 2018-12
  • 2018-11
  • 2018-09
  • 2017-01

Using this formula, one can fix this problem:

Year-Month= Data[a_date].[Year]&"-"&FORMAT(Data[a_date].[MonthNo],"00")

Year-Week= Data[a_date].[Year]&"-"&FORMAT((Data[a_date].[MonthNo],1),"00")