Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

sort date in slicer

hi all

any idea how i can sort the date , so that the lastest month is on the top? Thanks so much.

 

  • az38's avatar
    az38
    6 years ago

    Anonymous you didnt do sort by column.

    click left mouse on your YYYYMM column in the Fields Pane (right part of powerbi window) 

    then find and press button Sort by Column and choose YYYYMMdigits

    do not hesitate to give a kudo to useful posts and mark solutions as solution

    LinkedIn

  • az38's avatar
    az38
    6 years ago

    Hi Anonymous 

    your column [Calendar Month Number] stores month number without leading 0.

    to fix it you should either change format this field or rewrite column like this

    yyyymmdigit = if('Date'[Calendar Month Number]<10;CONCATENATE('Date'[Calendar Year];concatenate("0";'Date'[Calendar Month Number]));CONCATENATE('Date'[Calendar Year];'Date'[Calendar Month Number]))

    do not hesitate to give a kudo to useful posts and mark solutions as solution

      

9 Replies

  • az38's avatar
    az38
    Community Champion

    Hi Anonymous 

    create new column

    YYYYMMdigits = CONCATENATE('Date'[Fiscal Year];'Date'[Fiscal Month Sort Order])

    then pick your field YYYYMM in the Field Pane. Go to Sort By Column button and select YYYYMMdigits

    there is your sample file https://ufile.io/s3ouf2e0

     

    do not hesitate to give a kudo to useful posts and mark solutions as solution

    LinkedIn

      • az38's avatar
        az38
        Community Champion

        Anonymous you didnt do sort by column.

        click left mouse on your YYYYMM column in the Fields Pane (right part of powerbi window) 

        then find and press button Sort by Column and choose YYYYMMdigits

        do not hesitate to give a kudo to useful posts and mark solutions as solution

        LinkedIn

  • Anonymous ,

     

    By clicking on 3 dots on slicer and select Descending. Refer screen shot for your reference.

     

    Don't forget to hit THUMBS UP and mark it as a solution if it helps you!

  • v-lionel-msft's avatar
    v-lionel-msft
    Community Support

    Hi Anonymous ,

    What is the type of your [YYYYMM] column, Date or Text?

    If it's Date type, you can refer to Tahreem24 's answer.

    If it's Text type, you'd better to convert this column to a date type.

    So how does the column come from? is it your original data?

    If it comes from a combination of the other two columns, you can refer to az38 's answer.

    YYYYMM = CONCATENATE([YYYY]&" ", [MM])

    Then, convert this column to a date type.

     

    If the column is original data, firstly, you need to split the column, then regroup.

     

    Best regards,
    Lionel Chen

     

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

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks all...I finally got it.

      Mine was a text field, after the sorting, now it works!

       

      • az38's avatar
        az38
        Community Champion

        Hi Anonymous 

        your column [Calendar Month Number] stores month number without leading 0.

        to fix it you should either change format this field or rewrite column like this

        yyyymmdigit = if('Date'[Calendar Month Number]<10;CONCATENATE('Date'[Calendar Year];concatenate("0";'Date'[Calendar Month Number]));CONCATENATE('Date'[Calendar Year];'Date'[Calendar Month Number]))

        do not hesitate to give a kudo to useful posts and mark solutions as solution