Custom sort a pivot table but not data table

Kelsey Lubbe August 5, 2021

Hi all! 

I manage a program that uses tickets. My page currently has full data table displaying information about all tickets in the program with a pivot table that summarizes all tickets by status. The Table Filter macro will filter both pivot table and data table.

I would like to sort the pivot in an order defined by me rather than alphabetically. I tried to use Table Transformer with SQL query that does this (WHEN T1.'Status' LIKE "Escalation Review" THEN "1"...) but I think the Table Transformer is attempting to sort the data table and not the pivot table. 

Is there a way for me to use Table Transformer to apply only to pivot table? Or another macro to use? 

2.PNG1.PNG

2 answers

1 accepted

4 votes
Answer accepted
Katerina Rudkovskaya _Stiltsoft_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 5, 2021

Hello @Kelsey Lubbe

Please try this SQL query:

SELECT *
FROM T*
ORDER BY
CASE
WHEN T1.'Status' LIKE "Escalation Review" THEN 1
WHEN T1.'Status' LIKE "Root Cause Analysis" THEN 2
WHEN T1.'Status' LIKE "Corrective Action Plan" THEN 3
WHEN T1.'Status' LIKE "Pending Approval" THEN 4
ELSE 5
END

Katerina
Stiltsoft

Kelsey Lubbe August 5, 2021

Thanks, @Katerina Rudkovskaya _Stiltsoft_ . This is similar to the output I got previously. Screenshot here compared to output without Table Transformer. 

3.PNG

No Table Transformer

4.PNG

Katerina Rudkovskaya _Stiltsoft_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 6, 2021

Hi @Kelsey Lubbe ,

Note that in your case, you can change the order of columns just choosing them with the help of autocompletion in Table Transformer according to your needs.

Please see my exampe below:

2021-08-06_17h11_50.png2021-08-06_17h12_13.png

Use autocompletion: start typing, e.g., T1. and choose the column.

2021-08-06_17h14_13.png2021-08-06_17h12_04.png

Katerina
Stiltsoft

Kelsey Lubbe August 9, 2021

Hi Katerina, 

Thank you! That did sort the top pivot table in the appropriate order.

Is it expected that the full data table (from Table from CSV in original screenshot) is hidden? The reason why I have the Pivot Table and data table nested inside the Table Transformer macro is because I want the Table Filter macro to apply to both Pivot Table and data table. 

Andrey Khaneev _StiltSoft_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 9, 2021

Hi @Kelsey Lubbe,

You can set it to show or hide the source table in both Pivot Table and Table Transformer macros.

Kelsey Lubbe August 9, 2021

Oh my, I was expecting a checkbox to display/hide and did not expect a dropdown option. My bad on missing that! Thanks so much for the help @Andrey Khaneev _StiltSoft_ @Katerina Rudkovskaya _Stiltsoft_ !

Like # people like this
Sean M September 21, 2021

@Andrey Khaneev _StiltSoft_ I think I discovered an issue that simply needs some error handling.  It looks like if any of the defined columns does not have a task of that status (meaning count 0), it throws an error and the whole table will not display:

Error: Column does not exist: Count STATUSNAME

Does anyone have a recommendation on how to handle that scenario?  I have removed the column with a 0 count and the table displays correctly again.  However, we would like to display that column count when it does have tasks in that status... 

Thanks so much, the above info has been great in getting us this far!

Andrey Khaneev _StiltSoft_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 21, 2021

@Sean M, please try to use COALESCE function in this case:

COALESCE(T1.'Count STATUSNAME')
Randall Hinds May 30, 2023

@Katerina Rudkovskaya _Stiltsoft_  Thanks for the answer above.  It definitely solved for my similar column sorting challenge. 

I am using this solution to show Status Counts across a number of work efforts. 
Each Pivot Table is pulling Status Counts from a specific JQL statement from Jira Macro. 

SELECT T1.'Assignee',
T1.'Count Open',
T1.'Count In Progress',
T1.'Count On Hold',
T1.'Count Resolved',
T1.'Count Closed',
T1.'Count',
T1.*
FROM T*

When a JQL return does find any cards in Resolved Status, the Transformer SQL tells me so with Error: Column does not exist: Count Resolved
--> Is there a way I can sort all columns for Status, regardless of a card being in that status?

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2023

Hi @Randall Hinds ,

Isn't the Sean's question from Sep 21, 2021 similar to your case?

Please check the two comments right above yours: the question by Sean and the answer by Andrey about the COALESCE function.

Randall Hinds May 31, 2023

Thank you, @Stiltsoft support !  That function does let me arrange Status columns even when there are no cards to count in a particular Status. 

However, the header row shows the COALESCE function statement & adds so much empty space in the table.
2023-05-31_10-02-33.png

Even though the SELECT function lets me reorder Status where there are cards to Count, it is less visually appealing than simply letting a Pivot Table sort Status alphabetically.

Table Transformer example with SELECT function wrapper on Pivot
2023-05-31_10-11-37.png

example with only Pivot Table
2023-05-31_10-10-16.png

I want to reorder columns showing the colored names even when there are no cards in a particular Status...  It seems I can do all of these things, but I can't figure out how to do them at once.  
Is there a way I can have my cake & eat it too?

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2023

Hi @Randall Hinds ,

Seems that you've forgot to rename your columns:

COALESCE(T1.'Col 1') AS 'Col 1' (the same goes for every column)

 

For your case it may be very neat, cause you may get rid of the "Count" prefix:

COALESCE(T1.'Count Open') AS 'Open'

Randall Hinds May 31, 2023

It's like magic!  You guys rock me!

2023-05-31_11-55-03.png

SELECT T1.'Assignee',
COALESCE(T1.'Count Open') AS 'Open',
COALESCE(T1.'Count Defined') AS 'Defined',
COALESCE(T1.'Count In Progress') AS 'In Progress',
COALESCE(T1.'Count On Hold') AS 'On Hold',
COALESCE(T1.'Count Resolved') AS 'Resolved',
COALESCE(T1.'Count Closed') AS 'Closed',
COALESCE(T1.'Count') AS 'Total'
FROM T*

Like # people like this
0 votes
Sean M September 21, 2021

I think I discovered an issue that simply needs some error handling.  It looks like if any of the defined columns does not have a task of that status (meaning count 0), it throws an error and the whole table will not display:

Error: Column does not exist: Count STATUSNAME

Does anyone have a recommendation on how to handle that scenario?  I have removed the column with a 0 count and the table displays correctly again.  However, we would like to display that column count when it does have tasks in that status... 

Thanks so much, the above info has been great in getting us this far!

Added to reply section.  Please disregard this.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events