Table Filter and Charts field matching
Asked by Craig.Harley:

I am merging 2 confluence tables using Table Transformer and only want to display the merged list where the value of Table 1 Column A are contained within the contents of Table 2 Column B. Apologies if this is a really basic question, but have been struggling with this for a while.

Performing the Join is easy enough, just struggling to get my head around the matching

The following is as far as i have got (the original query is more complex but essentially this)

SELECT  
T1.'Column A',  
T2.'Column B'  
FROM  
T1  
JOIN  
T2  
ON T1.'Column A' LIKE T2.'Column B'

However this returns no results


Answers:
author: Tim Kopperud
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003) , if I understand the question correctly I'm not able to reproduce this error, that means I get values returned when trying this.

#### I have the following setup. {#toc-hId-289486142}

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

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

#### Result: {#toc-hId--1517968321}

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

#### Or with some added info: {#toc-hId-969544512}

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

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

Are you able to attach some images from your setup? It might help finding the root cause of the problem you experience.

TimK.

comments: author: Craig.Harley
body: thank for the reply Tim,

this looks identical to what I have done, the only difference being

I would be looking for something along these lines where you have A2 as a like for like match, instead I am trying to do the following

I would be looking to recognise "A2" in T1 Column A as a match for T2 Column B where the value in T2 Column B could be "entry1:A2 to documentRef1", but this would be a match

Can't really post what I have due to the nature of the content, but if needed could mock something up


author: Tim Kopperud
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003), I'm not sure I fully understand when you are saying "*entry1:A2 to documentRef1, , but this would be a match*". Sorry about that.

Yes, I suspect a simple mockup might be of help.

TimK


author: Craig.Harley
body: Hi Tim, it would be a match as "entry1:A2 to documentRef1" contains A2, apologies if I have been a bit vague

In addition with the format, the field matching would always be directly after the colon ":"

![mockup.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/291821i90DB8DF67E63134C/image-size/large?v=v2&px=999 "mockup.PNG")


author: Tim Kopperud
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003), if I have understood the question correctly this example might help

```
SELECT 
A, C, D
FROM 
T1
JOIN
T2
ON C::string->split(":")->1::string->split(" ")->0 = A
```

We here

* first split the string retunrned from C by ":" and then fetch the second value from the split array which is index 1, hence "-\>1"
* then we split the returned string by " " (space) and fecth the left most value which is split index 0, hence "-\>0"
* we can then match the result with A in the JOIN ON clause.

#### Result: {#toc-hId-289508212}

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

#### Source: {#toc-hId--1517946251}

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

Hope this helps.

TimK


author: Craig.Harley
body: hi Tim, tried this, but get the following error returned

![error.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/291887iEC90B6AA87E3ECA0/image-size/large?v=v2&px=999 "error.PNG")


author: Tim Kopperud
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003), strange. It works on my side.

Can you attach a picture of your SQL statement?

TimK


author: Stiltsoft support
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003) ,

[@Tim Kopperud](/t5/user/viewprofilepage/user-id/492874) has given a correct SQL query that also works pretty fine in our test environment. For the experiment we've used the source tables with dummy data that you provided.

Seems that indeed smth is missing in your SQL query or you try it on your real tables and they somehow differ from the provided examples.

You may share your screenshots here or refer to our [support](https://stiltsoft.atlassian.net/servicedesk/customer/portal/14) that is confidential. If you attach your page storage (upper right corner of the page -\> menu ... -\> View storage format), we'll be able to recreate exactly your page and macro settings and check what goes wrong.


author: Craig.Harley
body: as requested

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/291969i1EDE2A3EFEB68350/image-size/large?v=v2&px=999 "Capture.PNG")


author: Tim Kopperud
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003), I have tried to exactly match your SQL statement, and it still works fine on my side.

#### SQL {#toc-hId-289516117}

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

#### Source {#toc-hId--1517938346}

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

#### Result {#toc-hId-969574487}

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

Where are you getting the error you are refering to? I would expect the error to be right below the SQL statement as shown below where I here have added a syntax error, but I cannot see this in your attachment.

You might also share an image including the error to understand where it happens.

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

TimK.


author: Craig.Harley
body: Hi Tim, the error doesn't show up below the sql statement, but instead appears here

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/291993i95BDC4D52A1DC9F5/image-size/large?v=v2&px=999 "Capture.PNG")


author: Tim Kopperud
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003), I'm able to reproduse this error if I add an extra colon into the Summary column (see yellow marking below).

#### Error reprodused {#toc-hId-289516949}

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

#### Extra colon {#toc-hId--1517937514}

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

I suspect the case is as [@Stiltsoft support](/t5/user/viewprofilepage/user-id/5062270) mentioned earlier, that the table data differ from the example data.

Can you have a closer look into the data set and confirm that the Summary field in each record follows the rule used, as in what you stated earlier:
> ...the field matching would always be directly after the colon ":"

TimK.


author: Stiltsoft support
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003) ,

Maybe this more general option will do for you:

![Thu 9-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/292023i3B8D00F5A5CB7D86/image-size/large?v=v2&px=999 "Thu 9-1.png")

SELECT  
'Column A', 'Column B', 'Column C', 'Column D'  
FROM T1  
JOIN T2 ON T1.'Column C' LIKE "%" + T2.'Column A' + "%"

![Thu 9-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/292024i5382790E2EDCC8C7/image-size/large?v=v2&px=999 "Thu 9-2.png")


author: Craig.Harley
body: I found a single record where there was a double colon, changed to single and the error has disappeared. I'm just getting no rows returned now, which I will work through


author: Tim Kopperud
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003), glad I could be of help and that the error is gone. Just inform me here if you need further assistance with a way to return rows from the query. The formula suggested might need a little tuning to return records from your real data set.

TimK.


author: Craig.Harley
body: Hi Tim, thanks for all the help

I had a re-think about what I was trying to achieve and found a different route using a simpler SQL statement as there were other fields I could use as the key

so this is resolved now

once again, many thanks


author: Tim Kopperud
body: Hi [@Craig.Harley](/t5/user/viewprofilepage/user-id/4615003), thanks for accepting the answer. Yes, a simpler route is often a better approach. I hope you got it working as you wanted.

TimK.


author: Craig.Harley
body: hi Tim, tried the above and I get the following

![error.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/291886iD0A1B921A6EDC156/image-size/large?v=v2&px=999 "error.PNG")


Tags: cloud

confluence-cloud

filter

table