Hi,
I don't know what is the SQL you ran on SQL Server.
If you want to do a union in IDT, there is 2 options:
- You create a derived table in the data foundation like:
SELECT "Month", "LastYear", null as "ThisYear" FROM Where "the year you want to test" = @Prompt('Select the year','N')-1
UNION
SELECT "Month", null as "LastYear", "ThisYear" FROM Where "the year you want to test" = @Prompt('Select the year','N')
- You create a parameter that defines the "ThisYear" and "LastYear" using Prompts like I define in the SQL syntax.
The report creator define then the UNION in the query panel and select the parameters you have created.
But I recommend you that yoou create a derived table in the Data Foundation nwith 2 sub-select like this.
I assume that [Value] is the measure you want to aggregate
SELECT a.[Month], a.[Value] as [LastYear], b.[Value] as [ThisYear]
FROM
(Select [Month], [Value] FROM [dbo].[My_Table] WHERE [Year] = 2015) a,
(Select [Month], [Value] FROM [dbo].[My_Table WHERE [Year] = 2016) b
WHERE a.[Month] = b.[Month
Now, if you want to let the user choosing Last Year and This Year then you can create an @prrompt and change the SQL statement like this:
SELECT a.[Month], a.[Value] as [LastYear], b.[Value] as [ThisYear]
FROM
(Select [Month], [Value] FROM [dbo].[My_Table] WHERE [Year] = @Prompt('Select the year','N')-1) a,
(Select [Month], [Value] FROM [dbo].[My_Table WHERE [Year] = @Prompt('Select the year','N')) b
WHERE a.[Month] = b.[Month
Didier