Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I have created a matrix table to show the sales figures for my sales reps (rows), by week number (columns).
Problem is that the week numbers are being displayed in ascending order (1 to 52). Is there a way to show the week order in descending order instead?
Hi,
You cannot achieve this reverse sorting directly... here is a workaround:
1. Go to the Edit Query option of the Week dim table.
2. Apply Sort desc on the unique week code column (there must be a unique identifier for each week i.e. in my case I have WeekCode column as 20170101, 20170102, 20170103, 20170104, 20170205, 20170206.... YYYYMMWW where WW is the incremental week number of the year from 1 to 52.
3. Select 'Add Index column' from Add Column menu and provide Starting Index=1 and Increment=1 in the dialog box.
4. Rename column as appropriate.
4. Save Apply and Close the Edit Query
5. Use this Index as 'Sort By Column' wherever required.
This wont work in Direct Query mode. Is there another option
Hi ipsingh79,
I tried your suggestion but get an message saying
Sort by another column
We can't sort the 'Date' column by 'Index'. There can't be more than one value in 'Index' for the same value in 'Date'. Please choose a difference column for sorting or update the data in 'Index'.
Based on this message, I duplicated the 'Date' column, set Data Type: Whole Number, and sort 'Date' by this new field, but the Matrix still displays the oldest Date on the Left.
Hi Ink20a2,
My bad I forgot to update the post.
So here is the working solution:
1. Make sure your table has some column as FinancialWeekCode i.e. YYYYMMWW where WW is the WeekNo e.g. ...,20170103, 20170104, 20170205,...
2. Add custom column as : SorttWeekCode = 99991253 - [FinancialWeekCode]
3. Apply and Close the query editor.
4. Sort the Week Name column with SortWeekCode custom column.
Let me know if you still get any issue.
Thanks ipsingh79 that worked. I had been missing the step 2. as adding index hadn't worked, but the subtraction in that step gave the higher number to sort on. Brilliant!
I tried this but received the message
Sort by another column
We can't sort the 'Date' column by 'Index'. There can't be more than one value in 'Index' for the same value in 'Date'. Please choose a different column for sorting or update the data in 'Index'.
Based on this error message, I duplicated the 'Date' column and set Data Type: Whole Number. Sorted the 'Date' by this field, with no change. Matrix still displays the oldest week on the left. Any other suggestions?
I too have this issue. It is common that when using Dates as Columns to have the most current on the left and decend to the right.
Actually I was looking for a way to sort the column from largest to smallest by Quarter in the matrix. Mean that user can click on the particiular quarter column, the data will short accorrdinly to Asc or desc order in the matrix.
Quarter | 2015Q3 | 2015Q4 |
Country | Cost | Cost |
A | 11331 | 1041 |
B | 2246 | 2221 |
C | 2071 | 2051 |
D | 4934 | 120 |
In your pbix file or source file, make sure that the weeknumbers are listed as data type date or number in order for the sort to work. If it is text, it may struggle.
NOTE: i just re-read this and see where I made an incorrect assumption. Please disregard.
Proud to be a Super User!
Hello @pmdci
If your matrix looks like this one (week instead of month in my matrix), you just have to click to the week header and the sort should be inverted.
Sébastien
Hi,
Actually no... The rows are the salesperson and columns are the week numbers.
I'm also looking for this solution. Anyone know how to workaround this. This can be done in Excel but not in Power BI Desktop
User | Count |
---|---|
102 | |
91 | |
87 | |
79 | |
71 |
User | Count |
---|---|
113 | |
105 | |
101 | |
73 | |
65 |