Merging and removing dropdown values from Jira with Table Transformer
Asked by Aur?lien Thazet:

Hi everyone,

I try to get some values from Jira and consolidated them in a Table Transformer into Confluence. The table I get is look like this right now:

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

And here is what I want to have as a final table:

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

In a nutshell:

* I want to create one line per Jira Version and group Summary and Topic related on this line
* For the Topic column, I want to:
  * check all the Topics from my Jira issues to remove duplicates if they are some for the same Version line
  * Change their style by using Confluence status style

I already managed the first one thanks to the following SQL request:

```
SELECT T1.'Fix versions' AS 'Version',
CONCAT_VIEW_AGGR(FORMATWIKI('Summary' , " \n")) AS 'Summary',
CONCAT_VIEW_AGGR(FORMATWIKI('Topic' , " \n")) AS 'Topic'
FROM T*
GROUP BY T1.'Fix versions';
```

But I'm struggle with the Topic column. Any advice?


Answers:
author: Stiltsoft support
body: Hi [@Aur?lien Thazet](/t5/user/viewprofilepage/user-id/5373148) ,

Your SQL query is correct. If in the 'Topic' column coming from your Jira Issues macro you have statuses, then they will be grouped as statuses (with color lozenges). If you have comma-separated strings (plain text), then you'll receive grouped plain text.

With the help of the Table Transformer macro you are able to set statuses based on some condition. If your 'Topic' column had only one word per cell, we could check which word it is and set a correspondent status instead. But, as I see from your screenshots, there can be several different words per cell. So, this workaround won't do for the case.

comments: author: Aur?lien Thazet
body: Hello,

Thanks for your swift reply. I could have several statuses in one cell indeed. Do you have any workaround for this?


author: Stiltsoft support
body: Not sure that the workaround is worth the end goal but you may try the following structure:

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

The same Jira output is repeated twice.

**#1**

SELECT'Col 1',  
CONCAT_VIEW_AGGR(FORMATWIKI('Col 2' , " \\n")) AS 'Col 2'  
FROM T\*  
GROUP BY 'Col 1'

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

**#2**

SEARCH / AS @a EX('Col 3'-\>split(",")) /  
RETURN(@a-\>'Col 1' AS 'Col 1', @a-\>'Col 2' AS 'Col 2', _ AS 'Col 3') FROM T\*

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

**#3**

SELECT \*,  
CASE  
WHEN 'Col 3' LIKE "Done" THEN FORMATWIKI("{status:colour=Green\|title=Done}")  
WHEN 'Col 3' LIKE "New" THEN FORMATWIKI("{status:colour=Yellow\|title=New}")  
ELSE FORMATWIKI("{status:colour=Red\|title=Fail}")  
END AS 'Col 3'  
FROM T\*

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

**#4**

SELECT'Col 1',  
CONCAT_VIEW_AGGR(FORMATWIKI('Col 3' , " \\n")) AS 'Col 3'  
FROM T\*  
GROUP BY 'Col 1'

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

**#5**

Here we choose the standard Lookup preset by the 'Col 1' column.

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


author: Aur?lien Thazet
body: Thanks for the proposition. I tried to reproduced it and everything went fine until step 5. The tables aren't merging.

![2024-06-03 15_45_30-Edit - Confluence schedule based on Jira Epic - Aurelien Confluence Playground -.png](https://community.atlassian.com/t5/image/serverpage/image-id/327544i7D8CD8F027645665/image-size/large?v=v2&px=999 "2024-06-03 15_45_30-Edit - Confluence schedule based on Jira Epic - Aurelien Confluence Playground -.png")

I tried to OUTER JOIN them with the following SQL request:

```
SELECT T1.'Col 1',
T1.'Col 2',
T2.'Col 3'
FROM T*
OUTER JOIN T* ON T1.'Col 1' = T*.'Col 1'
```

<br />

But I got the below error:
> TypeError: Cannot read properties of undefined (reading 'Col 1')


author: Stiltsoft support
body: You don't need any requests for this, just choose the standard Lookup preset and the suitable column for merging (as it is only one, it will be set automatically):

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


author: Aur?lien Thazet
body: Thanks for your help. I think we are close of the final shape I'm looking for.

The only left is the status duplicates in Col 3. I would like to remove the duplicates in the same cell. Is it possible?


author: Stiltsoft support
body: You may add an additional Table Transformer macro between #2 and #3 with the following SQL query:

SELECT 'Col 1', 'Col 3'  
FROM  
(SELECT  
DISTINCT('Full String'),  
'Col 1', 'Col 3'  
FROM  
(SELECT 'Col 1' + 'Col 3' AS 'Full String',  
'Col 1', 'Col 3'  
FROM T\*))

Please note that on the real data set there may be low performance. Two Jira macros and six Table Transformer macros are more than enough, especially for Confluence Cloud.


author: Aur?lien Thazet
body: Thank you for your help. This fixes my problem.

As you mentioned it could be low performance for Confluence Cloud.


Tags: cloud

confluence-cloud

filter

table

table-filter

table-filter-and-charts

table-filter-charts-spreadsheets

table-transformer