Set expression for hidden ssrs

2019-09-06 19:42发布

I want to display only first 10 rows and hide remaining rows in a column.

what will be the expression for this (Set expression for: Hidden) in Tablix properties -> visibility -> show or hide based on expression.

My dataset name is Top50CustomerSQL; My Column name is Supplier;

Expression for this scenario please?

SQL Code

   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

2条回答
Luminary・发光体
2楼-- · 2019-09-06 20:21

I would put in a row number in your select query then in the tablix filter put an expression saying something like where row <= 10

In your SQL:

 ROW_NUMBER ( ) OVER ( [ PARTITION BY value_expression , ... [ n ] order_by_clause )  

In tablix filter expression:

=SUM(IIF(Fields!rn.Value <= 10, 1, 0), "DataSet")

In your Dataset,put it anywhere:

SELECT s.[CusNo] Supplier,
   row_number () over(ORDER BY(SELECT 0)) AS rn,
查看更多
乱世女痞
3楼-- · 2019-09-06 20:37

You can use RunningValue() to count how many rows have been shown so far in your report. A query like this should work in your group (or details) visibility expression:

=RunningValue(Fields!Supplier.Value, Count, "DataSet1") > 10

The answer by Neil Norris should be equally valid, assuming you're able to edit your dataset SQL.

查看更多
登录 后发表回答