Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Sort slicer by another column

Hello,
I created a slicer for filtering my table.

slicerMeasure = DISTINCT(myTable[ProductCode])
and then a column based on slicerMeasure
slicerMeasureColumn = slicerMeasure
then I put slicer element and in section:"Filters on this visual" I added slicerMeasureColumn

 

Its work but I want that the items in my slicer are sorting by another (Date) column in my table.
So like this:
slicerMeasure = DISTINCT(myTable[ProductCode]) ORDER BY DateColumn

How can I do it?

  • Hi, Anonymous ;

    You could  sort slicer columns by which column you wish to sort. I tested it:

    1.course column sort by Index column.

    2.sort by

    The final output is shown below:

    Or Can you post sample data  and expected output?
    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous ;

    You could  sort slicer columns by which column you wish to sort. I tested it:

    1.course column sort by Index column.

    2.sort by

    The final output is shown below:

    Or Can you post sample data  and expected output?
    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • PaulDBrown's avatar
    PaulDBrown
    Icon for Community Champion rankCommunity Champion

    I'm not too sure what you are after. Normally when you create a table to use as a slicer, you create a relationship between this slicer table and the corresponding field in your fact table. If you are working with dates it is also recommended that you create a date table. Here is an example:

     

    You then use the fileds from these tables for you slicers, visuals, filters and measures. The relationship will filter the rows to show thos selected in the slicer.

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Thank for your answer.
    And it is possible that I sorting "DProdukt REF" for example by a column date from Sales ?

    • PaulDBrown's avatar
      PaulDBrown
      Icon for Community Champion rankCommunity Champion

      If you create a Calendar Table, which is sorted chronologically, you use the fields from this Calendar table and they will be sorted accordingly.

      Or do you mean that the actual items in the slicer are sorted by dates from the sales table? If so, it can be done, but it won't be dynamic. 

      In my example, I created the slicer table using:

      Sorted Slicer =
      ADDCOLUMNS (
          VALUES ( Sales[Product REF] ),
          "Order",
              CALCULATE (
                  MAX ( Sales[date] ),
                  FILTER ( Sales, Sales[Product REF] = EARLIER ( Sales[Product REF] ) )
              )
      )
      

      You can then sort the Product Ref column by the "order" column (which is sorted in ascending order as a date)