Using Table filter can i define default sort for tables in confluence
Asked by Sandhya Srinivasan:

Created Tables in a confluence page

wrapped the table with table filter macro

Specified default sorting in the table view tab

Click on Save

Q1. unable to see the table getting sorted as specified.

Q2. if I enter more rows with values in the tables, will sort be retained.?


Answers:
author: Katerina Kovriga {Stiltsoft}
body: Hi [@Sandhya Srinivasan](/t5/user/viewprofilepage/user-id/4074985)

**For Q1:** It is not an expected behavior for the macro. As I understand, you sort a manually created table, not the macro generated one (if I am wrong, please, specify the macro then). After hitting the Save button, the sorting should be saved. Try to experiment with other columns/tables.

If the bug is still here, please, raise a support ticket and attach the page storage format - we'll recreate the page with your table and try to fix the issue (go to the right upper corner of the page -\> ... -\> View Storage Format).

**For Q2:** Newly added rows will be sorted immediately as is specified in the macro body.

The macro settings:

![Sort 1.png](https://community.atlassian.com/t5/image/serverpage/image-id/112045iB62BB362936509CF/image-size/large?v=v2&px=999 "Sort 1.png")Adding a new row:![Sort 2.png](https://community.atlassian.com/t5/image/serverpage/image-id/112046iD018EA467958253B/image-size/large?v=v2&px=999 "Sort 2.png")

The published page:

![Sort 3.png](https://community.atlassian.com/t5/image/serverpage/image-id/112047i9B480B082847D37C/image-size/large?v=v2&px=999 "Sort 3.png")

comments: author: Sandhya Srinivasan
body: Thanks for your help.

Yes, I manually created the table.

Also, I had the header with some merged column cells. I think there is a problem with the instance we have in our organization.

i see my tables like this now: Table header upside down. Sort did not happen.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/112069i1101506B0F797BCA/image-size/large?v=v2&px=999 "image.png")


author: Katerina Kovriga {Stiltsoft}
body: The problem is in the merged headers - there are several difficulties with them in Confluence. Try the following workaround: wrap your table in the Table Transformer macro (don't make any changes in the settings) and then in the Table Filter macro with the default sorting.

![Sort 5.png](https://community.atlassian.com/t5/image/serverpage/image-id/112082i25210A8CF1B975A6/image-size/large?v=v2&px=999 "Sort 5.png")![Sort 6.png](https://community.atlassian.com/t5/image/serverpage/image-id/112083iCEA5258A8E5265DE/image-size/large?v=v2&px=999 "Sort 6.png")The Table Transformer macro will adjust your complex merged headings into the simple ones and the default sorting will be applied as usual.


author: Sandhya Srinivasan
body: I did exactly what you have said..

i am not able to understand where the problem is.. see my tables below

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/112877iD1D2C3EF99B7EB48/image-size/large?v=v2&px=999 "image.png")

And this is how it shows after saving. Long table headings..

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/112878iEBB9E56A37CC697D/image-size/large?v=v2&px=999 "image.png")


author: Katerina Kovriga {Stiltsoft}
body: Hi [@Sandhya Srinivasan](/t5/user/viewprofilepage/user-id/4074985) ,

You've done everything right - the problem is that tables with merged cells are unsortable in Confluence. Here is [their ticket](https://jira.atlassian.com/browse/CONFSERVER-55217?jql=project%20%3D%20CONFSERVER%20AND%20resolution%20%3D%20Unresolved%20AND%20text%20~%20"merged%20cells%20sorting"%20ORDER%20BY%20priority%20DESC%2C%20updated%20DESC) where you can vote for the issue.

The Table Transformer macro helps to separate merged headings (see my previous screenshots and your own table - it is the reason that your headings are long, they are not merged and become sortable).

You can also exclude the Table Transformer macro and rearrange your headings manually so that there will be no merged cells.


Tags: confluence-server

server