对于不返回任何行的日期,SSRS显示默认值0

时间:2016-08-11 20:27:01

标签: mysql sql reporting-services

我希望你能帮助我解决我正在尝试创建的SSRS报告线图的问题。所以现在,我正在查询我们的数据库,以获得一天的卡数。每张卡都是数据库中的一个单独行。现在,我的图表使用cardCounts的总和作为Y轴,而对于X轴,它使用日期作为类别组。现在问题是,几天没有数据,因为我们当天没有创建卡片。因此,不是线图将那天包含为0值,而是完全跳过那一天(在下图中,2016年7月16日那天完全缺失)。我尝试在数据级别进行,但是当我执行“isnull”时它仍然无法正常工作。 Screenshot of issue

以下是我正在使用的查询:

SELECT dbo.ProductionSet.PSId,Convert(date,MIN(PSCreateTime)) AS CreateTime,isnull(MAX(dbo.ProductionSet.PSCardsInSet),0) AS CardCount,MAX(PrintJobMaster.PJMBatchid) AS BatchId,
isnull(DATEDIFF(SECOND,MIN(PaperPrintStart.PSTimeOf),MIN(PaperPrintDone.PSTimeOf)),0) AS PaperPrintSecs,
          isnull(nullif(DATEDIFF(Minute,MIN(ProductionSet.PSCreateTime),MIN(PaperCopyDone.PSTimeOf)),0),0) AS SecsToPaperOnPress
    FROM dbo.ProductionSet WITH (NOLOCK)
          LEFT OUTER JOIN PSStats PaperPrintStart WITH (NOLOCK) ON ProductionSet.PSId = PaperPrintStart.PSID AND PaperPrintStart.PSStatTo='1-1' AND PaperPrintStart.PJMID IS NOT NULL
          LEFT OUTER JOIN PSStats PaperPrintDone WITH (NOLOCK) ON ProductionSet.PSId = PaperPrintDone.PSID AND PaperPrintDone.PSStatTo='3-3' AND PaperPrintDone.PJMID IS NOT NULL
          LEFT OUTER JOIN PSStats PaperCopyStart WITH (NOLOCK) ON ProductionSet.PSId = PaperCopyStart.PSID AND PaperCopyStart.PSStatFrom='PA-D'
          LEFT OUTER JOIN PSStats PaperCopyDone WITH (NOLOCK) ON ProductionSet.PSId = PaperCopyDone.PSID AND PaperCopyDone.PSStatTo='PAD-D'
          LEFT OUTER JOIN PSStats EncodingStart WITH (NOLOCK) ON ProductionSet.PSId = EncodingStart.PSID AND EncodingStart.PSStatTo='R'
          LEFT OUTER JOIN PSStats EncodingDone WITH (NOLOCK) ON ProductionSet.PSId = EncodingDone.PSID AND EncodingDone.PSStatTo='M'
          LEFT OUTER JOIN dbo.PrintJobMaster WITH (NOLOCK) ON dbo.PrintJobMaster.PJMPSID=productionset.PSId 
WHERE ProductionSet.PSCreateTime >= '7/16/2016' and ProductionSet.PSCreateTime < '7/17/2016'  and PaperCopyDone.PSTimeOf is not null
       GROUP BY ProductionSet.PSID
       ORDER BY MIN(ProductionSet.PSId)

1 个答案:

答案 0 :(得分:0)

尝试在图表的Values中使用此表达式。

=Sum(
IIF(ISNOTHING(Fields!CardCount.Value),0,Fields!CardCount.Value)
)

enter image description here

对于x轴中的日期,它将生成0,并且具有空的y轴值。

  

请注意,您有两个值系列,因此您必须使用相同的值   两个字段的表达式。

如果这有帮助,请告诉我。