简体   繁体   English

计算报告中的可见记录数,而不是数据集中的可见记录数

[英]Count number of visible records in report, not in dataset

I have a report that shows me all columnames on a server. 我有一个报告显示服务器上的所有列名。 For each db the columname is used in it shows me what datatype is it is. 对于每个db,使用columname,它显示了它是什么数据类型。 Eg: 例如:

ColumnName | Type        | DB_Name

Teacher_id | varchar(25) | DB1
           | int         | DB2
Classroom  | varchar(25) | DB1
           | varchar(100)| DB2
Course_id  |  int        | DB2

You see that datatypes are grouped by ColumnName . 您会看到数据类型按ColumnName分组。 Now I have put in a filter on the ColumName grouping that only shows me the ColumnNames with more then one datatype. 现在我在ColumName分组上添加了一个过滤器,它只显示了包含多个数据类型的ColumnNames。

Teacher_id | varchar(25) | DB1
           | int         | DB2
Classroom  | varchar(25) | DB1
           | varchar(100)| DB2

But now when I do a countdistinct on ColumnName it shows me the total number of all columnames, also the ones that are hidden....... So it does not produce 2 but 3 I suspect that this is caused by the fact that filtering is done on the report and not on the dataset but I feel I should still be able to count the number of occurences of columname in the report..... I tried =count(reportitems!Columname.value) in the pageheader but that gives me the number of columnnames on that page, not in the report! 但是现在当我对ColumnName执行countdistinct时,它会向我显示所有列名的总数,也包括隐藏的那些.......所以它不会产生2但是3我怀疑这是由于这个事实导致的过滤是在报告上完成的,而不是在数据集上完成但我觉得我仍然可以计算报告中列名的出现次数.....我在页眉中尝试= count(reportitems!Columname.value)但是这给了我该页面上的列名数量,而不是报告中的!

What is happening here? 这里发生了什么? How do I count the number of ColumNames in the report? 如何计算报告中的ColumNames数量? Is there fe a reportheader instead of a pageheader that I could use? 是否有报告头而不是我可以使用的页眉?

  • COUNT(Fields!FieldName.Value) : Gives you the count of value in the current scope. COUNT(Fields!FieldName.Value):给出当前范围中的值计数。

  • COUNT(Fields!FieldName.Value,"yourDataSetName") : Gives you the count of value in the dataset. COUNT(Fields!FieldName.Value,“yourDataSetName”):为您提供数据集中的值计数。

  • COUNT(Fields!FieldName.Value,"yourGroupName") : Gives you the count of value in the current Group. COUNT(Fields!FieldName.Value,“yourGroupName”):为您提供当前组中的值计数。

You might have to return the desired value with your query if you are using filtering. 如果使用过滤,则可能必须使用查询返回所需的值。 Filtered values are not included in aggregates within groups. 过滤的值不包含在组内的聚合中。 However, please test this at the dataset level by doing the following: 但是,请通过执行以下操作在数据集级别对此进行测试:

Place a text box above the table or matrix and give it a value of COUNT(Fields!FieldName.Value,"yourDataSetName"). 在表格或矩阵上方放置一个文本框,并为其赋予值COUNT(Fields!FieldName.Value,“yourDataSetName”)。 If it does not equate then you will need to return this with your data. 如果它不等同,那么您需要将此数据与此一起返回。

Solution two 解决方案二

Open up Report Properties Code and add this custom code: 打开报告属性代码并添加此自定义代码:

Public Shared Dim _RenderedCount As Integer=0

Public Shared Function ReInitRenderedCount() As string
    _RenderedCount=0
    return ""
End Function

Public Shared Function UpdateRenderedCount() As string
        _RenderedCount = _RenderedCount +1
    return ""
End Function

Public Shared Function GetRenderedCount() As Int    
    Dim ret As Int  
    ret=_RenderedCount
    Return ret
End Function

I have added snippets like this before where basically you set a visible column with no background somewhere on your detail line, perhaps the last column. 我之前添加了这样的片段,基本上你在细节线上设置了一个没有背景的可见列,也许是最后一列。 Then you can set its value=Code.UpdateRenderedCount() which updates the rendered count but returns "". 然后你可以设置它的值= Code.UpdateRenderedCount(),它更新渲染的计数但返回“”。 You can then inspect and print the rendered count using label.value=Code.GetRenderedCount(). 然后,您可以使用label.value = Code.GetRenderedCount()检查并打印渲染的计数。

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

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