在 Power BI 分页报表的 URL 中传递报表参数Pass a report parameter in a URL for a paginated report in Power BI

适用对象:APPLIES TO: ✔️ Power BI 服务✔️ Power BI service ✔️ Power BI 分页报表✔️ Power BI paginated reports ✔️ Power BI Premium✔️ Power BI Premium ❌ Power BI Desktop❌ Power BI Desktop适用对象:APPLIES TO: ✔️ Power BI 服务✔️ Power BI service ✔️ Power BI 分页报表✔️ Power BI paginated reports ✔️ Power BI Premium✔️ Power BI Premium ❌ Power BI Desktop❌ Power BI Desktop

可通过在分页报表 URL 中包含报表参数,向报表传递报表参数。You can pass report parameters to a report by including them in a paginated report URL. 所有查询参数都可具有对应的报表参数。All query parameters can have corresponding report parameters. 因此,可通过传递相应报表参数来向报表传递查询参数。Therefore, you pass a query parameter to a report by passing the corresponding report parameter. 需要为参数名称加上 rp: 前缀,以便 Power BI 在 URL 中识别它。You need to prefix the parameter name with rp: for Power BI to recognize it in the URL.

报表参数区分大小写并使用以下特殊字符:Report parameters are case-sensitive and use these special characters:

  • URL 的参数部分中的空格将替换为加号 (+)。A space in the parameter portion of the URL is replaced with a plus sign (+). 例如:For example:

    rp:Holiday=Christmas+Day

  • 字符串的任何部分中的分号将被替换为 %3A 字符。A semicolon in any portion of the string is replaced with the characters %3A.

浏览器应自动执行正确的 URL 编码。Browsers should automatically perform the proper URL encoding. 不必手动对任何字符进行编码。You don't have to encode any of the characters manually.

若要设置 URL 内的报表参数,请使用以下语法:To set a report parameter within a URL, use the following syntax:

rp:parameter=value

例如,要指定在“我的工作区”的报表中定义的两个参数“Salesperson”和“State”,请使用以下 URL:For example, to specify two parameters, "Salesperson" and "State", defined in a report in your My Workspace,you'd use the following URL:

https://app.powerbi.com/groups/me/rdlreports/xxxxxxx-abc7-40f0-b456-febzf9cdda4d?rp:Salesperson=Tie+Bear&rp:State=Utah 

要指定在应用中的报表中定义的两个相同参数,请使用以下 URL:To specify the same two parameters defined in a report in an app, you'd use the following URL:

https://app.powerbi.com/groups/me/apps/xxxxxxx-c4c4-4217-afd9-3920a0d1e2b0/rdlreports/b1d5e659-639e-41d0-b733-05d2bca9853c?rp:Salesperson=Tiggee&rp:State=Utah 

若要为参数传递 Null 值,请使用以下语法:To pass a null value for a parameter, use the following syntax:

parameter:isnull=true

例如:For example:

rp:SalesOrderNumber:isnull=true

要传递布尔值,请使用 0 表示 false,使用 1 表示 true。To pass a Boolean value, use 0 for false and 1 for true. 要传递浮点值,请包含服务器区域设置的小数分隔符。To pass a Float value, include the decimal separator of the server locale.

备注

如果报表包含具有默认值的报表参数,并且“Prompt”属性的值为 false(即未在报表管理器中选择“Prompt User”属性),则不能在 URL 中为该报表参数传递值。If your report contains a report parameter that has a default value, and the value of the Prompt property is false (that is, the Prompt User property isn't selected in Report Manager), then you can't pass a value for that report parameter within a URL. 这样,管理员就可以选择阻止最终用户添加或修改某些报表参数的值。This provides administrators the option of preventing end users from adding or modifying the values of certain report parameters.

Power BI 不支持超过 2,000 个字符的查询字符串。Power BI does not support a query string of more than 2,000 characters. 如果使用 url 参数查看分页报表,则可以超过此值。This value can be exceeded if you are using url parameters to view your paginated report. 如果使用多值参数,则更是如此。It is especially true if you are using multi-value parameters.

其他示例Additional examples

以下 URL 示例包括一个多值参数“Salesperson”。The following URL example includes a multi-value parameter "Salesperson”. 多值参数的格式为的是重复每个值的参数名称。The format for a multi-value parameter is to repeat the parameter name for each value.

https://app.powerbi.com/groups/me/rdlreports/xxxxxxx-abc7-40f0-b456-febzf9cdda4d?rp:Salesperson=Tie+Bear&rp:Salesperson=Mickey 

以下 URL 示例为本机模式报表服务器传递值为“7/1/2005”的单个参数 SellStartDate。The following URL example passes a single parameter of SellStartDate with a value of "7/1/2005", for a native mode report server.

https://app.powerbi.com/groups/me/rdlreports/xxxxxxx-abc7-40f0-b456-febzf9cdda4d?rp:SellStartDate=7/1/2005

后续步骤Next steps