ssrs 级联参数_如何向SSRS移动报告添加参数

ssrs 级联参数

This article will explain detailed usage of parameters in mobile reports in SSRS. Parameterized reports are important because report readers want to filter and customize their report data with parameters and this option helps report readers to focus on particular data. A parameterized SSRS report uses parameters as an input value and filters the report data according to these parameters. In this article we will focus, in particular, on how to use parameters and data sources together and how can we manage the parameters in mobile SSRS reports.

本文将说明SSRS中移动报告中参数的详细用法。 参数化报告非常重要,因为报告阅读器希望使用参数过滤和自定义其报告数据,并且此选项可帮助报告阅读器专注于特定数据。 参数化的SSRS报告将参数用作输入值,并根据这些参数过滤报告数据。 在本文中,我们将特别关注如何一起使用参数和数据源以及如何在移动SSRS报告中管理参数。

In my previous article How to create a Mobile Dashboard with SQL Server Microsoft Mobile Publisher, I described various details of dataset creation methodology and designing mobile reports. I recommend taking a glance at the “Creating data source and dataset” section in this article because we will use the same dataset sample and skip data source and dataset creation steps.

在我以前的文章如何使用SQL Server Microsoft Mobile Publisher创建移动仪表板中 ,我描述了数据集创建方法和设计移动报告的各种细节。 我建议您看一下本文中的“创建数据源和数据集”部分,因为我们将使用相同的数据集样本,并跳过数据源和数据集的创建步骤。

使用参数自定义SSRS数据集 (Customizing SSRS datasets with parameters)

In this section, we will add a parameter to a dataset. The reason for doing this is that a mobile report connects to SQL Server Reporting Server and gets data over this dataset. Also, for our demonstration we must create a new dataset to get a list of parameters. This new parameter list dataset provides us with data to populate parameter values to mobile report. Now, we will connect to the SSRS web URL and click (…) three points and select Edit in Report Builder. This process allows us to edit the dataset and add parameter.

在本节中,我们将向数据集添加参数。 这样做的原因是移动报表连接到SQL Server Reporting Server并通过该数据集获取数据。 同样,为了进行演示,我们必须创建一个新的数据集以获取参数列表。 这个新的参数列表数据集为我们提供了将参数值填充到移动报告中的数据。 现在,我们将连接到SSRS Web URL,然后单击(…)三个点,然后在Report Builder中选择Edit 。 此过程使我们可以编辑数据集并添加参数。

To complete this dataset editing process we need to use the SSRS Report Builder. If you haven’t installed Report Builder before, you can click the Get Report Builder navigation image and easily download and install the Report Builder. Report Builder will open automatically for dataset editing if it was previously installed.

要完成此数据集编辑过程,我们需要使用SSRS报告生成器。 如果您以前没有安装过Report Builder,则可以单击Get Report Builder导航图像并轻松下载并安装Report Builder。 如果先前安装了Report Builder,它将自动打开以进行数据集编辑。

Visual Studio 2017/2015 is another option to edit the dataset but ensure that the SQL Server Data Tools (SSDT) installation is completed for Visual Studio.

Visual Studio 2017/2015是编辑数据集的另一个选项,但要确保已为Visual Studio完成SQL Server数据工具(SSDT)的安装。

We will customize the dataset query with parameter for which we want to filter the column with this parameter. This parameter name has to start with “@” sign.

我们将使用要使用此参数过滤列的参数来自定义数据集查询。 此参数名称必须以“ @”符号开头。

SELECT * 
FROM [dbo].[DemoForMobileReport]
WHERE SalesPerson IN (@SalesPerson)

After completing these steps, we will click Set Options Dataset and change the dataset parameter settings. In the Parameters tab we will change the data type of parameter to text and click Allow multiple values option. This option allows us to populate data when we select “All” option in the mobile report parameter. Then we will click Allow null value and then we can save the dataset to report server.

完成这些步骤后,我们将单击“ 设置选项数据集”并更改数据集参数设置。 在“参数”选项卡中,我们将参数的数据类型更改为文本,然后单击“ 允许多个值”选项。 当我们在移动报告参数中选择“全部”选项时,此选项使我们可以填充数据。 然后,我们将单击“ 允许空值” ,然后将数据集保存到报表服务器。

In this step, we will create a new dataset for parameter list. This dataset will populate the parameter data to a selection list in the mobile report. We will change the query in the Query Designer as below and then click the (!) exclamation button to execute the query and then click Save As. Be careful about the save as process as otherwise you may overwrite your previous dataset.

在这一步中,我们将为参数列表创建一个新的数据集。 该数据集会将参数数据填充到移动报告中的选择列表中。 我们将如下所示在查询设计器中更改查询,然后单击(!)感叹号按钮以执行查询,然后单击“ 另存为” 。 请注意另存为过程,否则可能会覆盖以前的数据集。

SELECT DISTINCT SalesPerson AS [KeyVal], SalesPerson AS [LabelVal]
FROM [DemoForMobileReport]

We will give a name to the parameter list dataset and then click the Save As button and save the dataset to the SSRS report server.

我们将为参数列表数据集命名,然后单击“ 另存为”按钮并将数据集保存到SSRS报表服务器。

After completing these steps, we will see two datasets when we connect the report server web URL. One of them is for report data and other one is for report parameter list data. In the mobile report designer, we will use both of them.

完成这些步骤后,当我们连接报表服务器Web URL时,我们将看到两个数据集。 其中一项用于报告数据,另一项用于报告参数列表数据。 在移动报表设计器中,我们将同时使用它们。

移动报告设计 (Mobile report design)

We will launch Microsoft SQL Server Mobile Report Publisher and then select the datasets from the SQL Server Reporting Service. Click Add data and select Report server, this process allows us to connect to SQL Server Reporting Service and select datasets which were previously saved.

我们将启动Microsoft SQL Server移动报表发布器,然后从SQL Server报表服务中选择数据集。 单击添加数据,然后选择报表服务器 ,此过程使我们可以连接到SQL Server报表服务并选择以前保存的数据集。

In the Connect to a server screen we will enter the report server web service URL and fill the proper credentials and then click Connect.

在“ 连接到服务器”屏幕中,我们将输入报表服务器Web服务URL并填写适当的凭据,然后单击“ 连接”

We will select and then add our report dataset (MobileReportDataset) and filter dataset (ReporParameterListDataSet).

我们将选择然后添加报表数据集(MobileReportDataset)和过滤器数据集(ReporParameterListDataSet)。

We will add these two datasets into a new mobile report and the mobile report dataset tab will look like the following image.

我们会将这两个数据集添加到新的移动报告中,并且“移动报告数据集”选项卡将如下图所示。

In the previous image you will notice a green image placed near the MobileReportDataset label. This green image defines that report dataset incudes parameter. Now, we will click Layout tab and two components in the report designer panel. The first one is a selection list which helps us to use parameter lists in reports and send parameter selections to the report dataset as a filter to data. Drag and drop the selection list to the report design panel. Another component is the number component which helps us to show total sales.

在上一张图像中,您将注意到MobileReportDataset标签附近的绿色图像。 此绿色图像定义了报表数据集包含参数。 现在,我们将单击“ 布局”选项卡和报表设计器面板中的两个组件。 第一个是选择列表,它可以帮助我们在报表中使用参数列表,并将参数选择发送到报表数据集,作为数据的过滤器。 将选择列表拖放到报告设计面板中。 另一个部分是数字部分,它可以帮助我们显示总销售额。

We will navigate the Data tab and make the settings of these two components. First of all, we will make the selection list setting. Specify the data settings of selection list which are in the below image.

我们将导航“数据”选项卡并进行这两个组件的设置。 首先,我们将进行选择列表设置。 在下图中指定选择列表的数据设置。

Now we will hook the selection list parameters to MobileReportDataset. Click the Setting button near the MobileReportDataset label and select Param.

现在,我们将选择列表参数挂接到MobileReportDataset。 单击MobileReportDataset标签附近的“ 设置”按钮,然后选择“ 参数”

In the set dataset parameters tab we will change the @SalesPerson value to Selected Items and then click Apply. With this setting we have created a bridge between selection list and @SalePerson dataset. When the end user selects any parameter, it directly goes through the dataset parameter.

在设置数据集参数选项卡中,我们将@SalesPerson值更改为Selected Items,然后单击Apply。 通过此设置,我们在选择列表和@SalePerson数据集之间建立了桥梁。 当最终用户选择任何参数时,它将直接通过数据集参数。

We will select the number component and change the following settings.

我们将选择数字部分并更改以下设置。

Finally, we will run our mobile report for test. Click the Preview button and run the report.

最后,我们将运行我们的移动报告以进行测试。 单击预览按钮并运行报告。

When we change the Sales Person, Total Sales value will automatically change. The first image shows the selection of one sales person (George) Total Sales and the second one shows all sales person total sales.

当我们更改销售人员时,“销售总额”值将自动更改。 第一个图像显示了一个销售人员(乔治)总销售额的选择,第二个图像显示了所有销售人员的总销售额。

When we run the profiler, we can see the parameter and query interaction.

当运行分析器时,我们可以看到参数和查询交互。

摘要 (Summary )

In this article we demonstrated parameterized mobile reports in SSRS. This type of mobile report is for development purpose of mobile devices. For this reason, using parameters make reports easier and offers a more functional and flexible user experience.

在本文中,我们演示了SSRS中的参数化移动报告。 这种类型的移动报告用于移动设备的开发目的。 因此,使用参数可以使报表更容易,并提供更实用和灵活的用户体验。

翻译自: https://www.sqlshack.com/how-to-add-parameters-to-ssrs-mobile-reports/

ssrs 级联参数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值