在 Power BI 服务中为分页报表创建嵌入数据集Create an embedded dataset for a paginated report in the Power BI service

本文介绍如何在 Power BI 服务中基于嵌入数据源为分页报表创建嵌入数据集。In this article, you learn how to create an embedded dataset, based on an embedded data source, for a paginated report in the Power BI service. 嵌入数据集包含在单个分页报表中,并在该报表中使用。Embedded datasets are contained in a single paginated report, for use in that report. 目前,发布到 Power BI 服务的分页报表需要嵌入的数据集和嵌入的数据源。Currently, paginated reports published to the Power BI service need embedded datasets and embedded data sources. 创建报表时,可以在 Power BI 报表生成器中创建嵌入数据源和数据集。You create the embedded data source and dataset in Power BI Report Builder, while you're creating your report.

在创建数据集之前,首先需要创建数据源。Before you can create the dataset, you need to create a data source. 若要了解详细信息,请参阅 Power BI 服务中分页报表的嵌入数据源See Embedded data sources for paginated reports in the Power BI service to learn how.

创建嵌入的数据集Create an embedded dataset

  1. 在 Power BI 报表生成器的“报表数据”窗格中,选择“新建” > “数据集” 。In the Report Data pane in Power BI Report Builder, select New > Dataset.

  2. 在“数据集属性” 对话框的“查询” 选项卡中,为数据集提供一个名称。In the Query tab of the Dataset Properties dialog box, give the dataset a name. 嵌入的数据源已存在于“数据源” 框中,或者,可以选择“新建” ,创建其他嵌入数据源。The embedded data source is already in the Data source box, or you can select New to create a different embedded data source.

    新建数据集

  3. 在“查询类型” 下,选择要用于数据集的命令或查询的类型。Under Query type, select the type of command or query to use for the dataset.

    • “文本” 运行查询以从数据集中检索数据。Text runs a query to retrieve data from the database. 这是默认设置,适用于大部分查询。It's the default and is used for most queries. 键入一个查询,或通过选择“导入” 导入一个预先存在的查询。Type a query or import a pre-existing query by selecting Import. 若要以图形方式生成查询,请选择“查询设计器” 。To build the query graphically, select Query Designer. 如果使用查询设计器生成查询,查询的文本将显示在此框中。If you use the query designer to build a query, the text of the query will appear in this box. 选择“表达式 (fx)” 按钮,使用表达式来动态地生成查询。Select the Expression (fx) button to use an expression to dynamically generate the query.
    • “表” 选择表内的所有字段。Table selects all the fields within a table. 输入要用作数据集的表的名称。Enter the name of the table that you want to use as a dataset.
    • “存储过程” 按名称运行存储过程。Stored Procedure runs a stored procedure by name.
  4. 在查询设计器中,可以查看数据集中的表和字段并与之交互,导入查询或作为文本编辑。In the Query Designer, you can see and interact with the tables and fields in the dataset, import a query, or edit as text. 还可以在此处添加筛选器和参数。You can also add filters and parameters here.

    查询设计器

  5. 在查询设计器中,选择“运行查询” 对其进行测试,然后选择“确定” 。In the Query Designer, select Run Query to test it, then select OK.

  6. 返回“数据集属性”对话框,在“超时(以秒为单位)” 框中,键入查询超时之前的秒数。默认值为 30 秒。Back in the Dataset Properties dialog box, in the Time out (in seconds) box, type the number of seconds until the query times out. The default is 30 seconds. “超时” 的值必须为空或大于零。The value for Time out must be empty or greater than zero. 如果为空,则查询不会超时。If it is empty, the query does not time out.

  7. 可以在其他选项卡上设置数据集的其他属性:You can set other properties for the dataset on the other tabs:

    • 在“字段” 选项卡上创建计算字段。Create calculated fields on the Fields tab.
    • 在“选项” 选项卡上设置高级选项。Set advanced options on the Options tab.
    • 在“筛选器” 和“参数” 选项卡上分别执行添加或更新操作。Add or update Filters and Parameters on their respective tabs.
  8. 选择“确定” Select OK

    报表在报表设计视图中打开。The report opens in Report Design View. 数据源、数据集和数据集字段集合显示在“报表数据”窗格中,可以继续设计分页报表。The data source, dataset, and dataset field collection appear in the Report Data pane, and you can continue designing your paginated report.

    报表设计视图中的数据集

后续步骤Next steps