简体   繁体   English

SSRS-行可见性表达式

[英]SSRS - Row visibility expression

I am using SSRS 2014. 我正在使用SSRS 2014。

I want to display only first 50 rows. 我只想显示前50行。 What will be the expression for this please. 请对此表达什么。

I used top n functionality it doesn't work. 我使用了top n功能,但无法使用。 So I thought to take another route to achieve the result via expression. 所以我想走另一条路,通过表达来达到目的。

Below image with out adding 'top n'. 下图未添加“ top n”。 In the below image I wanted to display only first 50 rows in Supplier column 在下图中,我只想在“供应商”列中显示前50行

在此处输入图片说明

Below image with adding 'top n'. 在下面的图片中添加“ top n”。 Then results are changed. 然后结果被改变。 Few rows in Concession column are missing. “让步”列中缺少几行。

在此处输入图片说明

SQL code is, SQL代码是

    SELECT  s.[CusNo] Supplier, 
RTRIM(CAST(s.[Customer] AS VARCHAR(50)) ) AS Name,
s.[ConcessionNo] Concession, 
RTRIM(CAST(s.[ConcessionName] AS VARCHAR(50)) ) AS ConcessionName,

sum(case when s.Date between convert(date,dateadd(wk, datediff(wk, 0, getdate()) - 1, 0) - 1) and convert(date,dateadd(wk, datediff(wk, 0, getdate()) - 1, 0) + 5) 
           then s.SELLINC else 0 end) ActualSales,

    sum(case when s.Date 
        BETWEEN         
             convert(varchar(10), DATEADD(day, DATEDIFF(day, '19000107', DATEADD(month, DATEDIFF(MONTH, 0, CONVERT(date, CONVERT(VARCHAR(4), (CASE WHEN MONTH(GetDate()) = 1 THEN CONVERT(VARCHAR(4), GetDate(), 112) - 1 ELSE CONVERT(VARCHAR(4), GetDate(), 112) END), 112) + '0101')), 30)) / 7  * 7, '19000107'), 120)
        AND        
             Convert(date, dateadd(wk, datediff(wk, 0, GETDATE()) - 1, 0) + 5)       
           then s.SELLINC else 0 end) YrToDateActual


FROM [dbo].[CustomerReports] s
WHERE s.BRN = 1 or s.BRN = 2 or s.BRN = 3 or s.BRN = 4 or s.BRN = 5  or s.SELLINC is null or s.SELLINC = '0'
GROUP BY s.[CusNo], s.[Customer], s.ConcessionNo, s.ConcessionName
order by YrToDateActual desc

Any help please? 有什么帮助吗?

If you want the first 50 suppliers, you should be able to use the following expression in the row visibility property: 如果要使用前50个供应商,则应该可以在行可见性属性中使用以下表达式:

=RunningValue(Fields!Supplier.Value, CountDistinct,"YourDataset") > 50 = RunningValue(Fields!Supplier.Value,CountDistinct,“ YourDataset”)> 50

The report should perform better if you put this expression as a filter on the group instead of a row visibility expression, but at the moment I can't test to confirm whether this expression would be allowed there. 如果将此表达式作为过滤器而不是行可见性表达式放在组中,则报告的性能应更好,但是目前我无法测试以确认是否可以在该表达式中使用该表达式。

Modify your ORDER BY clause to: 将您的ORDER BY子句修改为:
ORDER BY s.[CusNo], YrToDateActual desc ORDER BY s。[CusNo],YrToDateActual desc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM