you need to create a parameterized SQL query for the dataset and design the report layout
I will give you an example query just create yours like this one
DECLARE @TimeAggregation NVARCHAR(10) = @AggregationParameter;
WITH CTE AS (
SELECT
DATEADD(HOUR, DATEDIFF(HOUR, 0, [DateTime]), 0) AS Hour,
DATEADD(DAY, DATEDIFF(DAY, 0, [DateTime]), 0) AS Day,
DATEADD(MONTH, DATEDIFF(MONTH, 0, [DateTime]), 0) AS Month,
[Temperature],
[Pressure]
FROM
YourTableName
)
SELECT
CASE
WHEN @TimeAggregation = 'Hourly' THEN Hour
WHEN @TimeAggregation = 'Daily' THEN Day
ELSE Month
END AS DateTime,
AVG([Temperature]) AS AvgTemperature,
AVG([Pressure]) AS AvgPressure
FROM
CTE
GROUP BY
CASE
WHEN @TimeAggregation = 'Hourly' THEN Hour
WHEN @TimeAggregation = 'Daily' THEN Day
ELSE Month
END
ORDER BY
DateTime;
- Open SQL Server Data Tools (SSDT) and create a new report project.
- Add a new report to the project.
- Set up the data source to connect to your SQL Server.
- Create a new dataset for the report
- Create a report parameter named AggregationParameter with three available values: "Hourly", "Daily", and "Monthly". Set the default value as per your requirement
- Bind the AggregationParameter to the dataset parameter @AggregationParameter.
- Design the report layout