SSRS: Get values from a particular row of DataSet?

。_饼干妹妹 提交于 2019-12-12 09:37:22

问题


My dataset currently has 12 rows of data. Each representing data for a month. I would like to have variance of a column between to rows, the rows being last & last but one i.e., latest month and previous month's data.
It could have been simple if I were to work on tablix but thats not the case. I want those values for a textbox.

Any ideas on it anyone?


回答1:


I hope you are using SSRS 2008R2:

R2 introduced the Lookup function that is perfect for this scenario.

=Lookup( Fields!ProductUID.Value ,Fields!ProductID.Value,Fields!Price.Value,"PriceDataSet")

The Lookup function above will evaluate the first parameter ("Fields!ProductUID.Value") in the current dataset, then look for a matching value in the field specified in the second parameter ("Fields!ProductID.Value") in the dataset specified in the fourth parameter. The value of the third parameter is then evaluated in that row of the dataset and returned.

A little convoluted, but very helpful.

In your case, you can use this in a textbox with a calculated a static number:

=Lookup(
    Month(DateAdd(DateInterval.Month, -1, GetDate())),
    Fields!MonthID.Value,
    Fields!Name.Value,
    "DataSet1")

This should calculate a number for last month, then look for a match in DataSet1.



来源:https://stackoverflow.com/questions/8004672/ssrs-get-values-from-a-particular-row-of-dataset

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