Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,602
Community Members
 
Community Events
165
Community Groups

Rename Column Header based on Value from Second Table / Variable

Hello,

I would like to rename a column based on a value from a second table.  Is something like this possible? @Katerina Kovriga _Stiltsoft_ - I have copied you because you have been able to answer a bunch of my previous questions.

Thank you!

Emily

2022-06-09_7-02-47.png

1 answer

Hi @Emily Berg ,

I've been also puzzled with the case, but our developers found a solution using the PIVOT table function:

Thu 4-1.png

SELECT * FROM (
SELECT * FROM T1 LEFT JOIN T2 ON T2.'Index' = 2
)
PIVOT (FIRST('Key') for 'Header Key')

Thu 4-2.png

Seems that I've got your case right from the screenshot: we go to the second table, use a condition, select a value based on it and rename the column from the first table - the new name matches this value.

The additional "Index" column can be further hidden with the help of the Table Filter macro or additional Table Transformer macro.

@Katerina Kovriga _Stiltsoft_ - this is so great, thank you!  Let's see if we can go a step further - can we do multiple column header changes as once or do I need to wrap in multiple transformers?

SELECT *
FROM
(SELECT * FROM T1 LEFT JOIN T2 ON T2.'Index' = 1)
PIVOT(FIRST('Key') for 'Key Column', (FIRST('Summary') for 'Summary Column'))

Thank you!

Emily

I don't think that the PIVOT function supports multiple aggregation under one command. So you may use several Table Transformer macros and repeat the original query with different column names and conditions.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

209 views 1 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you