首页 > 解决方案 > Microsoft Report Builder:如何从表中的多值参数中显示选定的值?

问题描述

我正在使用 MS Report Builder v3.0 创建报告。作为本报告的一部分,我有一个多值参数(名为@Diagnoses)。这个参数的标签和一些值(被显示框的大小截断)如下所示:

在此处输入图像描述

我想要做的是在 2 列 tablix 中显示用户选择的标签/值(我尝试使用单独的文本框作为标签/值,但结果未对齐)。

然而,这似乎并不简单。我找到的最接近的方法是this,它将用户的选择存储在 xml 格式的内部参数中,然后查询此参数以从 xml 生成数据集。

因此,我像这样创建了生成 xml 的内部参数:

在此处输入图像描述

...我已经根据这些数据创建了一个数据集,并带有以下查询:

在此处输入图像描述

但是现在当我将这些值放入 tablix 时,标签和值现在位于不同的行上,如下所示:

在此处输入图像描述

有没有人有一个简单的方法来解决这个问题?

最好的祝愿

CJ

标签: reporting-servicesssrs-2008ssrs-2012ssrs-tablix

解决方案


OK - I've solved it (it's not pretty, but it works!)

Basically, the problem comes from having to use the join statement when creating the xml - you can't really put both the label information and the value information on the same row in the xml.

To get round this, you have to use two internal parameters to create two datasets - one for the labels column, one for the values column. The method for creating these is essentially the same as that shown above, except for the values parameter, the expression for the default value is:

enter image description here

...and for the labels parameter, it's this:

enter image description here

(by the way, make sure you set the available values to "None" for internal / hidden parameters - the expressions here are for the default values)

Then, when you create the values dataset, you use the following syntax in its query:

enter image description here

...and similarly for the labels dataset.

Finally, in the report, you create one matrix from each of the two datasets, then put them next to each other, using fixed row heights and setting "can shrink" / "can grow" to false so that they look like they're in the same table:

enter image description here

I hope this helps somebody!


推荐阅读