在Reporting Services中的同一图表中显示两行

时间:2015-01-09 11:53:51

标签: sql reporting-services charts

我想用ReportingServices构建一个报告。 所以我想在此报告中插入折线图。我想得到这个结果:

enter image description here

我希望在同一张图表中有两条线。第一行显示从WC-1到WC-4的结果,第二行显示从周一到周日的结果。

我曾想过要创建两个数据集,但是无法将更多数据集插入到唯一图表中。这是我的问题:

DECLARE @TemporaryTable TABLE 
                        (
                        Day NVARCHAR(100),
                        Value DECIMAL(12,5)
                        )

-- Get PO start and end time and the linkupID
DECLARE @DATA_START AS DATETIME
DECLARE @DATA_END AS DATETIME
DECLARE @MACHINE AS NVARCHAR(100)


DECLARE @Date as DATETIME
SET @Date = '2014-10-31'
DECLARE @ProductionLine AS NVARCHAR(100)
SET @ProductionLine = 'COMBINER001'


--THE USER SELECT A DATE, I SET THE DATA IN THE FIRST DAY OF WEEK
SET @DATA_START = dateadd(week, datediff(week, 0, @Date), 0);
--THE USER SELECT A DATE, I SET THE DATA IN THE LAST DAY OF WEEK
SET @DATA_END =DATEADD(wk, DATEDIFF(wk, 6, @DATA_START), 6 + 7)
SET @MACHINE= @ProductionLine


-- Collect downtimes
INSERT INTO @TemporaryTable (Day,Value) VALUES('KP-4',12),('KP-3',13),('KP-2',44),('KP-1',15)
INSERT INTO @TemporaryTable (Day,Value)
SELECT 
    datename(dw,mc.Data) as Date,
    k.Value
FROM
    Machine_Counter mc INNER JOIN 
    KPI_Value k ON (mc.Data = k.Data AND mc.Machine = k.Machine) 
WHERE 
    mc.CounterType = 1 AND 
    mc.Machine LIKE @MACHINE AND
    k.KPI = 3 AND
    mc.Data BETWEEN @DATA_START AND @DATA_END
ORDER BY mc.Data

SELECT Day,Value FROM @TemporaryTable

0 个答案:

没有答案