Accessing variable in SSRS function

僤鯓⒐⒋嵵緔 提交于 2019-12-23 01:29:11

问题


I have a report which lists items from different categories. Need to display category name only when it changes from the previously listed one. My approach is using a custom function to generate appropriate text, however need to persist the previous value somehow. Wanted to use report variable for that, but I'm not sure how can I set its value and access it within the function? Also, does my approach make any sense, or is there any simpler way of doing it?


回答1:


Sorry, managed to do it the way I wanted. If anyone would have similar issues, this is a function I added to "Code" section:

Public Function GetHeader (val as Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.Variable, ByVal header as Int32)

Dim title As String
title = ""

If (val.Value <> header) Then
Select Case header
Case "1" 
title = "header 1"
Case "2" 
title = "header 2"
Case Else 
title = "header last"
End Select
val.Value = header
End If

Return title

End Function

And this is how I call it from expression:

=Code.GetHeader(Variables!Header, Fields!YourProperty.Value)



回答2:


To me it seems you should use row groups. Create a row group by category and add group header that contains your category title. That way you don't need to store the value of the previous categories to see the change but the grouping handles it instead.



来源:https://stackoverflow.com/questions/33013504/accessing-variable-in-ssrs-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!