Forum Discussion

Filipe89's avatar
Filipe89
Frequent Visitor
3 years ago
Solved

Order matrix collum month year

Im having another struggle, i want do order this collums of the matrix from 2023-04,  2023-03, 2023-02 ,so on, i tried by query, the near i got was as the image. 

i have a collum named YearMonth, it is data type, and has YYYY-MM structure. So far i created a new collum name TYPE year to show me just the year, and then created a new collum to passed the values to negative 

Column = Year('Sold'[TYPE YEAR])*-1, than sorted YearMonth collum by it. 
 
any ideia on how to do it? 
  • You can add a new column to your date table with an expression like this

    MonthsFromNowReverse = DATEDIFF([Date], TODAY(), MONTH)
     
    and then use it as the Sort By column for your YYYY-MM column

     

    Pat

2 Replies

  • ppm1's avatar
    ppm1
    Icon for Solution Sage rankSolution Sage

    You can add a new column to your date table with an expression like this

    MonthsFromNowReverse = DATEDIFF([Date], TODAY(), MONTH)
     
    and then use it as the Sort By column for your YYYY-MM column

     

    Pat

    • Filipe89's avatar
      Filipe89
      Frequent Visitor

      Thank you,

      Just need to create one more column so that this solution could work. If i didnt it would give me an error that it was sorting by ir self.