Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Table Transformer - Select Through Multiple Items Within Key Cell - Unable to Join Tables

Good morning community!

I am trying to join two tables together, but my 'key' contains multiple items within a given cell.   Is there a way to index through each item within the cell to check for a match / join?

In the top table key SR-3679 is "tested by" three different "TER" links.  The bottom table provides the details for the individual "TER" issues.  I need to be able to either:

  1. Create a table with 3 separate rows for SR-3679 showing the details of each "tested by" TER OR
  2. Create a table and merge the details of all TER within the single SR-3679 row

Any suggestions, please!image.png

2 answers

1 accepted

Hi @Emily Berg ,

We've recreated your case here:

Thu 6-1.png

If you have the only one type of keys (TER-XX), then we suggest using the following SQL query (it will be a more reliable one):

SELECT * FROM T1
LEFT JOIN T2 ON T1.'Tested by'->split("TER-")->indexOf(REPLACE(T2.'TER Key', "TER-", "")) > -1

Thu 6-2.pngThu 6-3.pngIf you have other types of projects (keys), then you may use a simpler query:

SELECT * FROM T1
LEFT JOIN T2 ON T1.'Tested by'->indexOf(T2.'TER Key') > -1

 

Hope this helps your case. 

@Katerina Kovriga _Stiltsoft_ ,

This is AWESOME! Thank you very much for the response!  Could you elaborate on why the first solution would be more reliable (for my own edification)?

Emily

The first variant splits and then joins your keys strictly - as you can see, there is the name of your project "TER-" included into the 'split' and 'indexOf' sql functions.

If you work with another project, then you'll have other keys (for example, WER-13, WER-15, etc.) and put "WER-" for 'split' and 'indexOf' functions.

The second variant is a more general and simple one. It works, but the result table should be checked manually at first if you have multiple project names with similar key indexes to prevent any mismatching.

Thank you @Katerina Kovriga _Stiltsoft_ ,

As you pointed out, the general approach is less robust and I am now seeing an issue because of similarities with other keys.

I have another problem regarding this request - my key field is not just "TER-", rather its a custom field that contains other text, e.g. "TER-XXX | Status | Summary".  How would I break out just the key from this field in order to proceed with the split function mentioned above?

Emily

Hi @Emily Berg ,

Not to mess up the original query, I suggest wrapping your second table with the combined TER Key into a separate Table Transformer:

Fri 1-1.png

Use the following SQL query to split your strings by the " | " symbols:

SELECT T1.'TER Key'->split(" | ")->0 AS 'TER Key',
T1.'TER Key'->split(" | ")->1 AS 'Description',
T1.'TER Key'->split(" | ")->2 AS 'Description2',
T1.'TER Summary'
FROM T*

Fri 1-2.png

Fri 1-3.png

And here is the result table for the first Table Transformer with the original SQL query:

Fri 1-4.png

Hope this helps.

Works like a charm!

You're the best @Katerina Kovriga _Stiltsoft_ !

Emily 

@Katerina Kovriga _Stiltsoft_ ,

Now that I have expanded my use of this query, I am running into another issue.  I am getting partial matches when using the index query.

I have two tables:

One containing "Key", "Summary", "Tested By", and "Tested-By-Key"

One containing "TER Key" and "TER Summary".

I am using the following query to merge the two tables based on the T1.'Tested-By-Key' to T2.'TER Key':

SELECT * FROM T1
LEFT JOIN T2 ON T1.'tested-by-key'->indexOf(T2.'TER Key') > -1

For this example, there should only be one match - IVDTER-168, but a partial match of IVDTER-16 is also appearing in the joining operation.  Is there a different query that enables an exact match only?

Thank you,

Emily2021-07-26_11-45-16.png

Hi @Emily Berg ,

I think we should stick to the more specific SQL query that I mentioned first - the one that includes the name of the project.

If I remember your case right, you are trying to merge the two tables that look similar to this screenshot:

Mon 3-1.png

The second table was divided by the internal Table Transformer macro:

Mon 3-2.png

Now try to merge these two tables with the help of the following SQL query:

Mon 3-3.png

SELECT * FROM T1
LEFT JOIN T2 ON
T1.'Tested-by-key'->split("TER-")->indexOf(REPLACE(T2.'TER Key', "TER-", ""))>-1

Mon 3-4.png

As you can see, the TER-16 and TER-11 cells (with the orange background) weren't matched to the TER-168 and TER-118 by partial match.

Hi @Katerina Kovriga _Stiltsoft_ ,

Thank you for the fast reply.  This does work - but what about cases where the prefix ("TER-") is not always the same?  I could do a case within the query to extract just the number, but then I could get duplicates depending on the prefix...e.g. TER-147 and IVDTER-147.  Thoughts with this use case?

Thanks,

Emily

I'll consult with our developers tomorrow and get back to you - can't come up with a better idea for the case with different prefixes.

As a straightforward workaround, you may use several Transformers - each one for every prefix (I assume that one or both of your tables come from the Jira Issues macro, so you may filter and process every project separately). The result table could be combined using an additional Transformer with a standard Merge preset.

Hi @Emily Berg ,

Here I am with a rather complex SQL query from our developers:

Thu 1-1.png

Thu 1-2.png

SELECT * FROM T1
LEFT JOIN T2 ON
T1.'Tested-by-key'->match("(^|[0-9])" + T2.'TER Key' + "([^0-9]|$)")

Thu 1-3.png

As far as I can see, the query matches your case.

Yes, this is beautiful!  Thank you to @Katerina Kovriga _Stiltsoft_ and your team!

Emily

Are these tables a result of JIRA filters?

Anyway, if I understood your question right, then this might help:

You already have the table for SR issues (let this be T1)

Filter and create a separate table for all TER issues affected in your SR table(let this be T2), then with these 2 tables in the same table transformer macro:

SELECT
(SELECT T1.'Key' FROM T1 WHERE T2.'TER Key' IN T1.'Tested By') AS 'SR Key',
T2.'TER Key',
T2.'TER Summary',
...
any other columns
...
FROM T2

 This way you will have something like this:

ter.PNG

@Kántor Tibor  - Thanks for the response.  This works only for the first row of T1 data.  I need to be able to loop this function through a large T1 with multiple rows.  Is there a way to incorporate a while loop or  something similar to index through the entire T1 table?

Not sure why... I have the same setup, separating linked issues to different rows, and it loops through the whole T1 table. Might not be a while loop issue?

Suggest an answer

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

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

987 views 7 42
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