Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Table transformer with conditional SQL selects

Marc_Sternberg
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Nov 06, 2023

Hello everyone,

I want to use the table transformer macro to execute two SQL selects depending on a condition.

If the Project row in the table shown is filled, the Select command should then execute a different select than if the row is not filled.

I have already tried the following. However, this does not work.

Thank you very much for your help!

image.png

DECLARE @projekt VARCHAR(255) = (SELECT T2.'Projekt' FROM T2);
IF (@projekt = "")
SELECT T2.'Sortiment',T2.'Produktbereich',T2.'Dokument',T2.'System',T2.'Status',T2.'Projekt' FROM T2
ELSE
SELECT T2.'Sortiment',T2.'Produktbereich',T2.'Dokument',T2.'System',T2.'Status',T2.'Projekt', CONCAT("15.",T1.'Verkaufsstart (SOD) Monat'::string->split("/")->1,".",T1.'Verkaufsstart (SOD)'::string->split("/")->0) AS 'Verkaufsstart' FROM T1,T2 WHERE T1.'Projekte' LIKE T2.'Projekt'

 

image.png

1 answer

1 accepted

1 vote
Answer accepted
Marc Koppelaar
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.
Nov 07, 2023

Hi @Marc_Sternberg 

I would suggest you reach out to the support portal of Stiltsoft. As they are the vendor and developer of the app.

They could be able to tell you if this is an option in there app r not and they might see this a bug or a feature request.

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.
Nov 07, 2023

Hi @Marc_Sternberg

Please refer to our support portal as @Marc Koppelaar has kindly mentioned.

The Table Transformer macro is based on the AlaSQL library and includes some limited functions of the JavaScript, so all the cases should be implemented accordingly to their rules.

To apply the condition, we can use the CASE WHEN statement from the AlaSQL library.

So, for us to help you with the SQL query, please attach the page storage of your page (upper right corner of the page -> menu ... -> View storage format). Then we'll be able to recreate exactly your page with macros, queries, and source tables.

I also see that you have the Table Excerpt Include macro inside the internal Table Transformer macro - please attach the page storage of the page with the corresponding Table Excerpt macro as well.

And from the query I can see that if the project name is empty, then you want to show the second table as it is. If it is not empty, then you want to show some extra data from the first table and you need to find this data by the project name. If I've got you wrong, please describe the desired result in the ticket as well.

Like # people like this
Marc_Sternberg
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Nov 08, 2023

Hello everyone,

Nikita has helped me to understand the Macro.
I have placed an additional table transformer around the table, which now transposes the table.

With the following query it now works as desired.

 

DECLARE @projekt VARCHAR(255) = (SELECT T2.'Projekt' FROM T2);
IF (@projekt = "")
SELECT T2.'Sortiment',T2.'Produktbereich',T2.'Dokument',T2.'System',T2.'Status',T2.'Projekt' FROM T2
ELSE
SELECT T2.'Sortiment',T2.'Produktbereich',T2.'Dokument',T2.'System',T2.'Status',T2.'Projekt', CONCAT("15.",T1.'Verkaufsstart (SOD) Monat'::string->split("/")->1,".",T1.'Verkaufsstart (SOD)'::string->split("/")->0) AS 'Verkaufsstart' FROM T1,T2 WHERE T1.'Projekte' LIKE T2.'Projekt'


Thank you very much for your support.

 

Best wishes,

Marc

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events