Forum Discussion
Sort Column in based on the Row total values in Matrix visual
- 2 months ago
You can sort Matrix columns dynamically based on Row Total using a Rank measure + Sort by Column.
Since your column headers are dynamic, we need to rank them by the Total CTR value.
**SOLUTION:**
**Step 1: Create this Measure**
This calculates total CTR for each column
Total CTR =
VAR _CurrentCol = SELECTEDVALUE('Your table name')
RETURN
CALCULATE([CTR], ALL('YourTable'))[YourColumnHeader][YourRowFie
ld]
**Step 2: Create Rank Measure for Sorting**
Column Sort Rank =
RANKX(
ALLSELECTED('YourTable'),
[Total CTR],
,
DESC,
DENSE
)[YourColumnHeader]**Step 3: Apply the Sort**
1. Click on your `YourColumnHeader` field in the Fields pane
2. Go to `Column tools` tab > `Sort by column` > Select `Column Sort Rank`
**Result:**
Now columns will automatically sort from Highest Total to Lowest Total: CB | TQ | QW | AS | ER | YW
When new columns are added in future, they will also sort automatically based on Total row value.
**Important Notes:**
1. Replace `YourTable` with your table name
2. Replace `YourColumnHeader` with OD, YW, CB etc field
3. Replace `YourRowField` with LHR-PAR, PAR-LHR field
4. Turn OFF "Show items with no data" for Column field
This works because `RANKX` recalculates on every filter change, so when date filter changes, column order will also change.
Let me know if you need help with the exact field names. Happy to help!
We wanted to follow up to check if you’ve had an opportunity to review the previous responses. If you require further assistance, please don’t hesitate to let us know.
Hi SUMESHKUMAR22
Have you had a chance to look through the responses shared earlier? If anything is still unclear, we’ll be happy to provide additional support.