Table Transformer: SQL query for display data
Asked by Ajay Shenoy:

I am struggling to display data using table transformer using multiple user IDs fields.

Created a Table Expert where I am capturing some of SME. Named the table expert on a different confluence page as **SME**. Below is sample data, I am trying to replicate

SME User ID

Person A p0s0abc

Person B. p1s1abc

Person C. p2s2abc

**Sample SQL Query**

SELECT T2.'Key',T2.'Linked Issues',  
T2.'Reporter',  
T1.'SME'

FROM T1  
LEFT JOIN T2  
ON T1.'User ID' IN T2.'Technical Lead'

**This sample query works fine** and is able to provide results as expected. Now, I am trying to make this a bit complex by adding another User ID Field, here is where I am facing a challenge where SQL is not recognising the query. Tried using And/OR but is giving varied results.Works fine with visualisation of data if I use the 2nd Table expert individually. But when I club them, I am not able to get the desired result.

SELECT T2.'Key',T2.'Linked Issues',  
T2.'Reporter',  
T1.'SME',' T1.Dev POC

FROM T1  
LEFT JOIN T2  
ON T1.'User ID' IN T2.'Technical Lead', 'T2.Participants'

Is there a solution to this challenge?


Answers:
author: Katerina Rudkovskaya [Stiltsoft]
body: Hi [@Ajay Shenoy](/t5/user/viewprofilepage/user-id/2304157),  

Not sure that I've got the case. The T2 comes from the Jira Issues macro, the T1 comes from the Table Excerpt Include macro and looks like the structure you provided ('SME' and 'User ID' columns). At first, you look up these two tables by T2.'Technical Lead' and T1.'User ID' columns. It means that when the 'Technical Lead' and 'User ID' data matches, the specific rows are combined.  

Then, as I understand, you get another field T2.'Participants' via the same Jira Issues macro (as you are referring to the column as T2). How does this field look for you and how does it correlate with the 'Technical Lead' field that is present in the same Jira Issues macro?  

Like, for example, you take the T1.'User ID' field, check if it matches the T2.'Technical Lead' and if no, then check the T2.'Participants' which may contain several User IDs?  

Also didn't get the "Works fine with visualisation of data if I use the 2nd Table expert individually. But when I club them, I am not able to get the desired result." part. About which Table Excerpt Include we are talking here?

comments: author: Ajay Shenoy
body: [@Katerina Rudkovskaya \[Stiltsoft\]](/t5/user/viewprofilepage/user-id/3738229)

Thanks for revert.

Let me explain again in different form. I have written a JQL which displays 50 + records in confluence in filter view. Only problem I have is Technical Lead, Participants, Approver field in Jira when showing in confluence shows alias name instead of a Name. For example : My name- Ajay S shows as a0x0abc instead which is a Alias name.

**Step 1** - Created a Sample Confluence Page and added them in a table expert and named the expert as **contacts.**Added 3 records for my technical lead field

**SME User ID**

Ajay S a0x0abc

Person B. p1s1abc

Person C. p2s2abc

**Step 2 -** Added a table filter and created a panel and added the Jira Filter which pulls my records for JQL. Included the table expert include macros and named the Expert name **contacts**and selected the source to select from specify page and add the page details which is able to show the 3 records.

**Step 3-**Added Table transformer and dragged the Table expert Include + Filter query within this and wrote a sample SQL query

*SELECT T2.'Key',T2.'Linked Issues',*   
*T2.'Reporter',*   
*T1.'SME'*

*FROM T1*   
*LEFT JOIN T2*   
*ON T1.'User ID' IN T2.'Technical Lead'*

When the '**Technical Lead'** and '**User ID'** data matches, the specific rows are combined and shown in Confluence in **SME Field.** This gives me desired results which shows the Issue Key, Linked Tickets, Reporter and when there match of technical lead this shows in **SME** field in my confluence filter view.

Now I would like to do the same for participants/approvers field and display the column in confluence for the same Jira Key. All the 3 fields(Technical Lead, Participants,Approver) are jira fields for same Jira Issue Key.

I tried this approach. Created a 2nd Table expert and named it **Dev POC** and now included table expert in **Step 3.**Edited the SQL query in table transformer to looks something like this

**Dev POC User ID**

Ajay S a0x0abc

Person B. p1s1abc

Person C. p2s2abc

*SELECT T2.'Key',T2.'Linked Issues',*   
*T2.'Reporter',*   
*T1.'SME'*

*T1.'Dev POC'*

*FROM T1*   
*LEFT JOIN T2*   
*ON T1.'User ID' IN T2.'Technical Lead' , T2.'Participants'*

*Now comma after 'Technical lead gives me a error. Tried And/Or operator. This either duplicates the record or show invalid information.*

*Is there a solve for this where I want to display Technical Lead, Participants,Approver as a name instead of alias name when pulling the records in filter view in confluence for an Single Jira Issue Key.Is there something wrong in my SQL query/Table Expert which I need to correct?*


author: Katerina Rudkovskaya [Stiltsoft]
body: Hi [@Ajay Shenoy](/t5/user/viewprofilepage/user-id/2304157),

I can suggest the following workaround:

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

Here you may use the Pivot Table macro or the third external Table Transformer macro (we'll use them later for grouping).Also I've taken my screenshots for Data Center, so my macros are nested directly on the page. For Cloud you'll need to recreate the same structure inside the [Table Toolbox](https://docs.stiltsoft.com/tfac/cloud/how-to-use-table-toolbox-macro-42245927.html?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) macro. Other steps will be the same.Here is your SQL query for the internal Table Transformer macro:

SELECT T1.'Key',  
T2.'SME' AS 'Technical Lead Name',  
T1.'Participants'  
FROM T1  
LEFT JOIN T2 ON T1.'Technical Lead' = T2.'User ID'

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

Here is the SQL query for the second Table Transformer macro:SELECT T1.'Key', T1.'Technical Lead Name',  
T2.'SME' AS 'Participants Names' FROM T1  
LEFT JOIN T2 ON T1.'Participants'-\>indexOf(T2.'User ID') \> -1

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

Now we need to group our issues as they were at the beginning of our manipulations.We can use the Pivot Table macro with more friendly UI:

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

Or the third external Table Transformer macro:SELECT T1.'Key', T1.'Technical Lead Name',  
SUM(T1.'Participants Names' + " ") AS 'Participants Names'  
FROM T\*  
GROUP BY 'Key', 'Technical Lead Name'

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

Hope it helps your case.


author: Ajay Shenoy
body: Dont think this will work for my case. As the above query is picking from Static table we have created and displaying.

1- I have a predefined JQL filter(public saved filter) which I am using to display 50+ Records and has these column ( **Key, Technical Lead, Participants, Approver, Epic Name, Epic/Theme**) from Jira project

2- Now I would like to display all these column for a single Jira Issue Key through a filter view in Confluence.

3- I would like to rename Technical Lead as **SME** , Participants as **Dev POC** , Approver as **QE.** Currently all 3 fields show alias name **SME** , **Dev POC** , **QE.**These should show actual name of user and not alias name.

Along with these fields it should also display the Key and look who is the SME, Dev POC, QE, Epic name,Epic/Theme and display them in filter view in confluence. User ID fields(**SME, Dev POC, QE**) should show name of user and not alias name.

Sample User ID Table( Dev POC/QE- Will have name of user)

**SME User ID. Dev POC QE**

Ajay S a0x0abc. a1x0abc a2x0abc

Person B p1s1abc. a1x0abc a2x0abc

Person C. p2s2abc. a1x0abc a2x0abc

When we do get a Solve this is future state I am looking. Epic Name \& Epic/Theme have the below sample information filled on Jira Key which should fetch and display based on JQL filter(public saved filter) I have provided for 50+ records.

**Key SME Dev POC QE Epic Name Epic/Theme**

Jira-123 Ajay Shenoy Jennifer Michael Content Creation Web

Can you suggest a solve of this problem or work around ?


author: Stiltsoft support
body: Hi [@Ajay Shenoy](/t5/user/viewprofilepage/user-id/5151387) ,

There is no any difference if the tables are static or coming from the Jira Issues macros. It's just that for our examples we take static tables because we don't have all the required fields in our test Jira to match different use cases.

So, you may adjust the queries for your needs using the principles from the previous answer: use several Table Transformer macros and several User ID tables to subsequently join them and replace IDs by real names (each JOIN will replace one column).

If you need to replace one User ID in a cell, then you use the first query structure (the standard JOIN, you have this structure in your question). As I see, this is your case.

If you have a string of IDs in a cell (for example, "id1, id2, id3"), you'll need the second query from our example.


Tags: atl-gruland

cloud

filter

table

table-filter-and-charts

table-transformer