Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago

Sorting dates in a slicer

I need to be able to sort these dates by month in the slicer. There is n't any column in the Sort By Column list that works to sort these.

 

 

7 Replies

  • Hi Anonymous , Hope you are doing well.
    I tried to replicate your problem considering that you have a date column in your table, please write below DAX to create another column : 

    Now select the "Month selection" column and use "Sorting" column to sort it as shown below : 

    Output : 

     

    if this helps please mark it as the solution else provide additional details for your problem.

     

    Thanks,

    Ankita

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I'm getting this syntax error trying to create the new calculated column

      My year calcualted column is 

       

      • AnkitaaMishra's avatar
        AnkitaaMishra
        Super User

        Anonymous please write below formula : 

        Sorting =
        VAR DateYear = VALUE(LEFT('Date'[Year], 4))
        VAR DateMonth = MONTH(DATEVALUE('Date'[Month Number] & " 1"))
        RETURN DateYear * 100 + DateMonth

        Please replace the table and column name according to your table. 

        You are getting an error because you are creating a VARIABLE but not returning the output.
         
         
  • Hi Anonymous 

     

    Is your column in date format? I think not because if it was in Date format you can easily sort it.

     

    If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Its a text field and I can't convert it to Date without getting this error below. Here is whats in the field.