Sort Page Properties Report by status
Asked by Micha Roon:

I have a Page Properties Report in my page and the pages contain a Status field. I'm trying to sort by that but it does not work

Here is my configuration

![Screenshot 2020-01-30 at 15.37.51.png](https://community.atlassian.com/t5/image/serverpage/image-id/81165i029868782CE0BC26/image-size/large?v=v2&px=999 "Screenshot 2020-01-30 at 15.37.51.png")


Answers:
author: Diego
body: Hello [@Micha Roon](/t5/user/viewprofilepage/user-id/3533004) !

As I understand, you ++*need to sort the order of items within your Page Properties Report macro based on the contents of the Status column.*++

The problem we are facing here is that we are ++*trying to order a macro*++, which is not a "raw" value for the editor or the Page Properties Report Macro.

I tried to order the values based solely on the macro but was also unable to. My workaround was to ++*add a value right beside the Status Macros of my pages with the Page Properties macros.*++Like this:

![value00.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/81380i9B1A4F8D43DC7289/image-dimensions/408x127?v=v2 "value00.jpg")

When I did that, all pages were ordered as expected. Here is how it looks like:

![value01.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/81381i8DE62FE2D9E48BB3/image-dimensions/468x103?v=v2 "value01.jpg")

I hope this helps you out, Micha! Looking forward to your reply.

comments: author: Micha Roon
body: I also thought of this and it works, but it's a bit ugly. I guess this feature is missing.


author: Kelly Pelkie
body: hi [@Diego](/t5/user/viewprofilepage/user-id/1188952) I'd like to follow on to this, if I may. My team is similarly using macros and we'd like to sort too. We have tried to put in a leading number to get the sorting to work instead of a letter. I've tried a few different forms/formats for this to no avail.

Here's what I'm getting sorting on "Numerical" via the macro Sort settings - no idea what it's doing (sorting on the alpha num and priority fields yield similarly illogical results):  
![numerical sort.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/157753i88120043F17BF9B1/image-size/large?v=v2&px=999 "numerical sort.PNG")  

The more annoying part is, somewhere in there, it knows how to sort this data by the status macro label value. If I manually click on any of the column headings for Alpha Num, Numerical, or Priority, data is ordered the way that I would expect:![sort by heading.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/157754i9D780160DD8B3206/image-size/large?v=v2&px=999 "sort by heading.PNG")

How can I configure my Page Properties report Sort settings to achieve this? I've tried all manner of adding/excluding asc/desc to the Sort parameter, in conjunction (and not) with the "Reverse Sort" option - nothing works. Any ideas?


author: Katerina Kovriga {Stiltsoft}
body: Hi [@Kelly Pelkie](/t5/user/viewprofilepage/user-id/4478950)

If you look back at the screenshots, you'll see the difference: your numbers are included into your statuses. But for his example Diego put also plain text before the Status macro.

Not "\[1-High\]", but "1\[1-High\]"


author: Kelly Pelkie
body: Hi [@Katerina Kovriga {Stiltsoft}](/t5/user/viewprofilepage/user-id/1464746)   
I see that - thanks for pointing that out. What do you make of the manual column sorting getting those labels into the order I'd expect without needing to do anything additional to the data in those fields? Any plans to expose whatever metadata option it's reading from to users so that we could set that same sort parameter by default?  
The status macro is handy and useful for visually grouping items, but that depends on the ability to sort as one would expect.


author: Katerina Kovriga {Stiltsoft}
body: I can suggest trying our app - [Table Filter and Charts for Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-and-charts-for-confluence?tab=overview&hosting=cloud) (it is a paid add-on). Maybe you've already been using it for your Confluence - it works with the Page Properties Report macro perfectly well.

You'll be able to filter your report by statuses (like in Excel) and [sort](https://docs.stiltsoft.com/display/public/TFAC/Sorting%2C+freezing+and+other+table+viewing+options#Sorting,freezingandothertableviewingoptions-Applythedefaultsortingordertocolumns) them with the help of the [Table Filter](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+Filter+macro) macro.

[Here](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+the+app+with+Page+Properties+Report) are even more dashboards based on the app and the Page Properties Report macro.


author: Kelly Pelkie
body: Thanks for the suggestion for that add on. I'll have to see if that's something we could get. I appreciate the examples too!


author: Torkil Johnsen
body: One way of solving this, with vanilla Confluence cloud and no extra applications, and without "hacking" with adding numbers to help the sorting by having numbers in front of the status labels, or sorting numbers in a separate column:

1. Add a Table Transformer macro (or a Table Toolbox macro with a Table Transformer macro inside it if you want to)  

2. Inside this Table Transformer macro, add a Page Properties Report like in the original question in this discussion.  

3. Create a normal table inside the Table Transformer macro, below the Page Properties Report. This table will map status names to their ordering in integers. For instance: ToDo = 1, In progress = 2, Done = 3.  

   We will now JOIN the two tables by the status column, allowing us to order the joined table by the integers. This allows every status label to get their ordering defined once and in one place.  

4. Add something like the following SQL query to the transformer:  
   SELECT T1.'Title', T1.'Status', T1.'Contact'  
   FROM T1  
   LEFT JOIN T2 ON T2.'Status' = T1.'Status'  
   ORDER BY T2.'Ordering'  

   This will map the ordering column onto the data table, allowing you to use it for sorting, but without displaying it.  

   Here, T1 is the first table (Page Properties Report) and T2 is the second table (The one that maps status to order number)

This is an example of my status ordering table:

![status ordering.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/219277iED0A90404D5E0DA5/image-size/large?v=v2&px=999 "status ordering.jpg")

comments: author: Katerina Kovriga {Stiltsoft}
body: Hi [@Torkil Johnsen](/t5/user/viewprofilepage/user-id/4580799) ,

Thank you for the description of your workaround!

But please note that the [Table Transformer](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+Transformer+macro?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) macro you've kindly mentioned above belongs to the [Table Filter and Charts for Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-and-charts-for-confluence?tab=overview&hosting=cloud&utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) app (the plugin is developed and supported by our company).

Not to confuse other Community members, the app is not installed by default and it is a paid one unless your Cloud instance is small (1-10 users).


author: Torkil Johnsen
body: Haha, I stand corrected, thanks ;)


author: Stiltsoft Support
body: Hello [@Micha Roon](/t5/user/viewprofilepage/user-id/3533004) and [@Kelly Pelkie](/t5/user/viewprofilepage/user-id/4478950) ,

If you work with many statuses in the Page Properties Report macro, [Handy Macros for Confluence](https://marketplace.atlassian.com/apps/1214971/handy-macros-for-confluence-formatting-and-interactive-ui?tab=overview&hosting=cloud&utm_source=atlassian-community&utm_medium=answer&utm_campaign=handy-macros-traffic-sources&utm_vendorID=1216111&utm_content=page_properties) can help you do it much faster. Handy Status can be changed in the page view mode and filtered with Table Filter and Charts later on.


Tags: cloud

confluence-cloud

filter

sort

table

table-filter

table-filter-and-charts