Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Table Transformer - how to add column of values based off two other columns values

Charles Middlebrooks January 28, 2024

I have a table that details Platform and Model fields, but does not have a column that combines the two. For example, I need any row that shows the Platform column as XXX and the Model column as YYY to generate a new column called Router and input the value XXX YYY. I feel like im close but dont understand SQL that well . . . 

 

SQL.JPG

1 answer

1 accepted

2 votes
Answer accepted
Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2024

Hi @Charles Middlebrooks ,

The Table Transformer macro is based on the AlaSQL library and you may check the examples of different use cases, queries and syntaxes in our documentation here and here.

For your current case you may use the following structure:

Mon 1-1.png

SELECT
T1.'Platform',
T1.'Model',
FORMATWIKI(T1.'Platform' + "-" + T1.'Model') AS 'Router'
FROM T1
WHERE T1.'Platform' LIKE "B" AND T1.'Model' LIKE "456"

Mon 1-2.png

Seems that it is smth similar to your original request or at least gives you some hints how to move on.

Charles Middlebrooks January 29, 2024

Yes, this solves what I needed! For a future question though, how would I keep the remaining columns in my table currently and just add the new one to the end? Rather than limiting it to just selecting the two and creating the third?

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2024

The format

SELECT
T1.'Column 1', T1.'Column 2', T1.'Column 3', T1.'Column N'
FROM T1

equals 

SELECT *
FROM T1

So, as I have only 2 columns in my source table and I want to show both of them, I can use not only this query

SELECT
T1.'Platform',
T1.'Model',
FORMATWIKI(T1.'Platform' + "-" + T1.'Model') AS 'Router'
FROM T1
WHERE T1.'Platform' LIKE "B" AND T1.'Model' LIKE "456"

but this query as well

SELECT *,
FORMATWIKI(T1.'Platform' + "-" + T1.'Model') AS 'Router'
FROM T1
WHERE T1.'Platform' LIKE "B" AND T1.'Model' LIKE "456"

If you need to show only specific columns or change the order of your columns, you may list them manually.

If you want to show all the source columns as they are, you may use *.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events