Forum Discussion

bantoszewski's avatar
bantoszewski
Frequent Visitor
1 year ago
Solved

custom sorting in a matrix table

Hi,

 

I have the following table:

ProductMonthSalesVolume
A15040
A26030
A34020
B14030
B23020

 

which I would like to show in matrix with a sorting by Sales (ascending or descending) but always keeping the months chronological (ascending).

By default the sorting is made on each rows so the months are messed up:

After watching https://www.youtube.com/watch?v=pM_8zsPidRk on RANKX function I created a measure:

Ranking Sales = RANKX(
    ALLSELECTED(products[Product]),
    [SalesAm])
and put the ranking column into the matrix.

Months are ok, but it is not what I want. It misses all the user friendliness.

I would like to sort the Sales by pressing these little triangles but in a way that the months are always shown ascending.

So it should look like:

Is there a way to achieve this?

If not by triangles maybe there is any other sollution? For example by making the "ranking" column invisible and by adding in some sorting buttons which would change the "ranking" column method?

  • SamWiseOwl's avatar
    SamWiseOwl
    1 year ago

    Hi bantoszewski 
    You can use calculate on your measure to remove the Month filter to rank the products

    Rank measure =
    RANKX(
        ALLSELECTED('Test Table'[Product])
        ,CALCULATE([SalesAm],ALLSELECTED('Test Table'[Month]))
        ,
        ,DESC
        ,Skip
    )
     
    If the year/month are from a seperate calendar table you could do AllSelected(CalendarTable) or if they are from the sale Date column use AllSelected(table[date]). If the same table different columns AllSelected(table[month],table[year]).

6 Replies

  • Hi bantoszewski 

    Have you tried using bookmarks?

    You can save the visual how you want it sorted.

    Then save it sorted the opposite direction.

    Then assign both of these to images/shapes etc such as a little arrow on the visual.

     

    You could also turn WordWrap off and shrink the rank column down to hide it.

     

    • bantoszewski's avatar
      bantoszewski
      Frequent Visitor

      I thought about bookmarks but then what about using slicers, for example on chosen products or on certain dates? As far as I'm concerned the bookmarks remebers all filters.

      • SamWiseOwl's avatar
        SamWiseOwl
        Super User

        Hi bantoszewski 

        Bookmarks can save the settings of an entire page or single/groups of visuals:

         

        When you save the bookmark only select the table and NOT the slicers.

        That way it only save the table not the visuals.