Reporting Services - setting a field value dynamically based on parameter

混江龙づ霸主 提交于 2019-12-23 09:06:16

问题


I need to build a report that shows data in four grouped levels. The tricky part is: the actual fields to be displayed on those four levels are to be passed into the report as parameters.

My main issue right now is this: how can I tell a textbox on the report to not display the value of the parameter @X, but the value of the field by the name which is specified in parameter @X?

So if I pass in @X = 'Agent', I don't want to show 'Agent' on the report, but really

=Fields!Agent

but how can I do that? It seems to me that those value expressions are all pretty much hardcoded - is there a way to define

=Fields!(@X) 

or something like that - show the field which corresponds to the name passed to the report in parameter @X ?

This is probably absolutely silly - but I'm hitting a brickwall right now and can't seem to find a way around it....


回答1:


It is

=Fields(Parameters!X.Value).Value

as specified here

Edited to be correct: I forgot once you use an = (expression) you have to address the parameter differently.




回答2:


Is the source data for the report arranged in such a way that you could define a second datasource which looks up the field values for parameters 1-4 and returns them as a single row, to which you could then refer in the report using the first syntax?

=First(Fields!Param1.Value, "Param_Lookups")


来源:https://stackoverflow.com/questions/1905833/reporting-services-setting-a-field-value-dynamically-based-on-parameter

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