Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Sort by columns by value in Matrix Visual

I have a table contains ID and Week columns as below

IDWeek
001Week1
002Week2
003Week2
001Week3
003Week3
003Week3

And I use these 2 to create the Matrix Visual, and the value is Count of ID (I want to calculate how many times that each ID shows in different weeks)
The Matrix Visual is as below:

 Week1Week2Week3Total
0011 12
002 1 1
003 123

Now I can sort by Total column.
Here is my question, is it possible to sort by weekly value in DAX or Measure?
Like if I want to sort by Week3, the visual will change to:

 Week1Week2Week3Total
003 123
0011 12
002 1 1
     


Any answer will be helpful! Thanks!!

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

     

    First of all, thanks amitchandak  for the quick reply. I have a few other thoughts to add:

    (1) My test data is the same as yours.

    (2) For example, you want to sort by Week3. We can create measures.

    Measure = COUNT('Table'[Week])
    Measure 2 = 
    var _week="Week3"
    var _count=MAXX(FILTER(ALL('Table'),[ID] in VALUES('Table'[ID])&&[Week]=_week),[Measure])
    return _count

    (3) Sort by [Measure2] in descending order. Then manually adjust the column width to hide Measure2 and turn off "text wrap".

     

    Best Regards,

    Neeko Tang

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

3 Replies

  • Anonymous , As of now you can not sort on Matrix column file value. You can sort on GT of the column field

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak , Thank you for your reply!
      About GT, how to sort on GT? Do I need to use ISINSCOPE function?
      An example will be really helpful!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    First of all, thanks amitchandak  for the quick reply. I have a few other thoughts to add:

    (1) My test data is the same as yours.

    (2) For example, you want to sort by Week3. We can create measures.

    Measure = COUNT('Table'[Week])
    Measure 2 = 
    var _week="Week3"
    var _count=MAXX(FILTER(ALL('Table'),[ID] in VALUES('Table'[ID])&&[Week]=_week),[Measure])
    return _count

    (3) Sort by [Measure2] in descending order. Then manually adjust the column width to hide Measure2 and turn off "text wrap".

     

    Best Regards,

    Neeko Tang

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