如果没有值,如何在组中显示实线?

时间:2016-09-22 20:10:33

标签: tsql reporting-services group-by

我需要在我的行组中在2015年下显示实线。 在我输入表达式=IIF(Fields!YearNum.Value=2015,"Solid",Nothing)的属性中 但是因为几个月没有价值观,这条线路被打乱了。 enter image description here

解决这个问题的方法是什么?

这是tablix的t-sql

SELECT      CAST(B.YearNum as varchar(10))+ ' Submitted'  as Type,
                1 as OrderNum,
                ISNULL(COUNT( ControlNo),0) Count,
                b.YearNum, b.MonthNum, b.MonthName
    FROM        tblCalendar b 
                    LEFT JOIN   ClearanceReportMetrics a  ON b.MonthNum = MONTH(a.EffectiveDate) AND b.YearNum=YEAR(a.EffectiveDate)
                    AND CompanyLine = 'Argonaut Insurance Company' AND Underwriter <> 'Batcheller, Jerry' 
    WHERE       YEAR(EffectiveDate) IN (2016, 2015) 
    GROUP BY    b.YearNum, b.MonthNum,b.MonthName

UNION ALL

    SELECT      CAST(b.YearNum as varchar(10)) +' Quoted'  as Type,
                2 as OrderNum,
                ISNULL(SUM(CASE WHEN QuotedPremium IS NOT NULL THEN 1 ELSE 0 END),0) as Count,          
                b.YearNum, b.MonthNum,b.MonthName
    FROM        tblCalendar b 
                    LEFT JOIN   ClearanceReportMetrics a  ON b.MonthNum = MONTH(a.EffectiveDate) AND b.YearNum=YEAR(a.EffectiveDate)
                    AND CompanyLine = 'Argonaut Insurance Company' AND Underwriter <> 'Batcheller, Jerry'
    WHERE           YEAR(EffectiveDate) IN (2016, 2015)  --AND CompanyLine = 'Plaza Insurance Company' AND Underwriter <> 'Batcheller, Jerry'
    GROUP BY    b.YearNum, b.MonthNum,b.MonthName

UNION ALL

        SELECT  CAST(b.YearNum as varchar(10)) +' Bound' as Type,
                3 as OrderNum,
                ISNULL(sum(case when TransactionType = 'Policy' then 1 ELSE 0 END),0) as Binds,
                b.YearNum,
                b.MonthNum,             
                b.MonthName             
                FROM    tblCalendar b
        LEFT JOIN   ProductionReportMetrics a ON b.MonthNum = MONTH(a.EffectiveDate) and b.YearNum = YEAR(a.EffectiveDate) --Coming from Production Report, NOT from Clearance!!!!!!!!!!!
                AND CompanyLine = 'Argonaut Insurance Company' AND Underwriter <> 'Batcheller, Jerry'
        WHERE   b.YearNum IN (2016, 2015)
        GROUP BY b.YearNum,b.MonthNum,b.MonthName   

UNION ALL

    SELECT      CAST(b.YearNum as varchar(10)) +' Declined' as Type,
                4 as OrderNum,
                ISNULL(SUM(CASE WHEN  Status = 'Declined' THEN 1 ELSE 0 END ),0) as  Count,
                b.YearNum, b.MonthNum,b.MonthName
    FROM        tblCalendar b 
                    LEFT JOIN   ClearanceReportMetrics a  ON b.MonthNum = MONTH(a.EffectiveDate) AND b.YearNum=YEAR(a.EffectiveDate)
                    AND CompanyLine = 'Argonaut Insurance Company' AND Underwriter <> 'Batcheller, Jerry'
    WHERE       YEAR(EffectiveDate) IN (2016, 2015)
    GROUP BY    b.YearNum, b.MonthNum,b.MonthName

还尝试将NULL值更改为0.但仍然给出了相同的结果 enter image description here

2 个答案:

答案 0 :(得分:0)

你可以像这样处理缺失的值:

=IIF(Fields!YearNum.Value=2015 Or IsNothing(Fields!YearNum.Value) = 1,"Solid",Nothing)

答案 1 :(得分:0)

我找到的解决方法是: 在属性中,BotderStyle 对于Top我写了表达式:

=IIF(Fields!Type.Value="2016 Quoted","Solid",
IIF(Fields!Type.Value="2016 Bound","Solid",
IIF(Fields!Type.Value="2016 Declined","Solid",
Nothing)))

对于Bottom表达式:

=IIF(Fields!Type.Value="2015 Submitted","Solid",
IIF(Fields!Type.Value="2015 Quoted","Solid",
IIF(Fields!Type.Value="2015 Bound","Solid",
Nothing)))

所以基本上这些线相互抵消,填补了空白。