在 Power BI 中创作模板应用的提示Tips for authoring template apps in Power BI

在 Power BI 中创作模板应用时,其中一部分是创建工作区、测试和生产的后勤工作。When you're authoring your template app in Power BI, part of it is the logistics of creating the workspace, testing it, and production. 但其他重要的部分显然是创作报表和仪表板。But the other important part is obviously authoring the report and the dashboard. 我们可以将创作过程细分为四个主要部分。We can break down the authoring process into four main components. 使用这些组件有助于创建最佳模板应用:Working on these components helps you create the best possible template app:

  • 通过“查询”,连接转换数据,并定义参数With queries, you connect and transform the data, and define parameters.
  • 在“数据模型”中,可以创建关系度量值和问答的改进 。In the data model, you create relationships, measures, and Q&A improvements.
  • 报表页中包括视觉对象和筛选器,以帮助洞察数据 。Report pages include visuals and filters to provide insights into your data.
  • 仪表板磁贴提供对内含见解的概览 。Dashboards and tiles offer an overview of the insights included.
  • 示例数据让应用在安装后可被立即发现。Sample data makes your app discoverable immediately after installation.

你可能熟悉其中每个部分(作为现有 Power BI 功能)。You may be familiar with each piece as existing Power BI features. 在构建模板应用时,每个部分还有其他考虑事项。When building a template app, there are additional things to consider for each piece. 请参阅下面的每个部分以获取更多详细信息。See each section below for more details.

查询Queries

对于模板应用,在 Power BI Desktop 中开发的查询用于连接数据源和导入数据。For template apps, queries developed in Power BI Desktop are used to connect to your data source and import data. 必须使用这些查询返回一致的架构,并且它们受支持以用于计划的数据刷新(不支持 DirectQuery)。These queries are required to return a consistent schema and are supported for Scheduled Data refresh (DirectQuery isn't supported).

连接到 APIConnect to your API

需要从 Power BI Desktop 连接到你的 API 才能开始生成查询。To get started, you need to connect to your API from Power BI Desktop to start building your queries.

可以使用 Power BI Desktop 中的数据连接器来连接到 API。You can use the Data Connectors that are available in Power BI Desktop to connect to your API. 可以使用 Web 数据连接器(获取数据 -> Web)连接到 Rest API 或 OData 连接器(获取数据 -> OData 数据源)来连接到 OData 数据源。You can use the Web Data Connector (Get Data -> Web) to connect to your Rest API or the OData connector (Get Data -> OData feed) to connect to your OData feed.

备注

目前,模板应用不支持自定义连接器,建议探索使用 Odatafeed Auth 2.0 作为一些连接用例的缓解措施,或提交你的连接器以供认证。Currently template apps do not support custom connectors, it is recommended to explore using Odatafeed Auth 2.0 as a mitigation for some of the connection use-cases or to submit your connector for certification. 若要详细了解如何开发并认证连接器,请查看数据连接器文档For details on how to develop a connector and certify it check the Data Connectors documentation.

考虑源Consider the source

查询可定义包含在数据模型中的数据。The queries define the data that's included in the data model. 根据你系统的大小,这些查询还应包括筛选器以确保客户处理适合你业务方案的可管理的查询量。Depending on the size of your system, these queries should also include filters to ensure your customers are dealing with a manageable size that fits your business scenario.

Power BI 模板应用可并行执行多个查询,也可同时为多个用户执行查询。Power BI template apps can execute multiple queries in parallel and for multiple users concurrently. 请提前规划你的限制条件和并发策略,并就如何使你的模板应用具备容错能力向我们寻求帮助。Plan ahead your throttling and concurrency strategy and ask us how to make your template app fault tolerant.

架构实施Schema enforcement

确保你的查询能够弹性应对系统中发生的更改,刷新时的架构变更可破坏模型。Ensure your queries are resilient to changes in your system, changes in schema on refresh can break the model. 如果源可能为某些查询返回 NULL 或架构缺失结果,请考虑返回空表或有意义的自定义错误消息。If the source could return null or missing schema result for some queries, consider returning an empty table or a meaningful custom error message.

参数Parameters

Power BI Desktop 中的参数允许你的用户提供用于自定义数据(由用户检索)的输入值。Parameters in Power BI Desktop allow your users to provide input values that customize the data retrieved by the user. 提前考虑这些参数以避免在耗费时间生成详细的查询或报表之后返工。Think of the parameters up front to avoid rework after investing time to build detailed queries or reports.

备注

模板应用支持除 Any 和 Binary 之外的所有参数。Template apps support all parameters except Any and Binary.

其他查询提示Additional query tips

  • 确保正确键入所有列。Ensure all columns are typed appropriately.
  • 列具有描述性名称(请参阅问答)。Columns have informative names (see Q&A).
  • 对于共享逻辑,请考虑使用函数或查询。For shared logic, consider using functions or queries.
  • 目前,该服务不支持隐私级别。Privacy levels are currently not supported in the service. 如果收到有关隐私级别的提示,则可能需要重写查询以使用相对路径。If you get a prompt about privacy levels, you may need to rewrite the query to use relative paths.

数据模型Data models

定义明确的数据模型可确保客户可轻松直观地与模板应用进行交互。A well-defined data model ensures your customers can easily and intuitively interact with the template app. 在 Power BI Desktop 中创建数据模型。Create the data model in Power BI Desktop.

备注

应在查询中执行大部分基本建模(键入功能、列名)。You should do much of the basic modeling (typing, column names) in the queries.

问答Q&A

建模还影响问答为客户提供结果的能力。The modeling also affects how well Q&A can provide results for your customers. 确保将同义词添加到常用列,并在查询中为列正确命名。Ensure you add synonyms to commonly used columns and you've properly named your columns in the queries.

其他数据模型提示Additional data model tips

请确保已完成以下操作:Make sure you've:

  • 将格式应用于所有值列。Applied formatting to all value columns. 在查询中应用类型。Apply types in the query.
  • 将格式应用于所有度量值。Applied formatting to all measures.
  • 设置默认汇总。Set default summarization. 特别是“不汇总”(如果适用)(例如,对于唯一值的情况)。Especially "Do Not Summarize", when applicable (for unique values, for example).
  • 设置数据类别(如果适用)。Set data category, when applicable.
  • 根据需要设置关系。Set relationships, as necessary.

报表Reports

报表页提供了对更多模板应用中包含的数据的见解。The report pages offer additional insight into the data included in your template app. 使用报表中的页面来回答模板应用正尝试解决的关键业务问题。Use the pages of the reports to answer the key business questions your template app is trying to address. 使用 Power BI Desktop 创建报表。Create the report using Power BI Desktop.

其他报表提示Additional report tips

  • 每页使用多个视觉对象进行交叉筛选。Use more than one visual per page for cross-filtering.
  • 仔细使各视觉对象对齐(不重叠)。Align the visuals carefully (no overlapping).
  • 页面设置为“4:3”或“16:9”布局模式。Page is set to "4:3" or "16:9" mode for layout.
  • 所提供的全部聚合将使数字有意义(平均值、唯一值)。All of the aggregations presented make numeric sense (averages, unique values).
  • 切片产生合理结果。Slicing produces rational results.
  • 徽标至少位于报表顶部。Logo is present on at least the top report.
  • 元素最尽可能地位于客户端的的配色方案中。Elements are in the client's color scheme to the extent possible.

仪表板Dashboards

仪表板是与客户的模板应用交互的主要位置。The dashboard is the main point of interaction with your template app for your customers. 它应包括所含内容(尤其是你业务方案的重要指标)的概述。It should include an overview of the content included, especially the important metrics for your business scenario.

要为模板应用创建仪表板,只需通过“获取数据”>“文件”上传 PBIX 或者直接从 Power BI Desktop 进行发布即可。To create a dashboard for your template app, just upload your PBIX through Get Data > Files or publish directly from Power BI Desktop.

其他仪表板提示Additional dashboard tips

  • 在固定时保持相同的主题,以便仪表板上的磁贴保持一致。Maintain the same theme when pinning so that the tiles on your dashboard are consistent.
  • 将徽标固定到主题,以便使用者知道包的来源。Pin a logo to the theme so consumers know where the pack is from.
  • 建议用于多数屏幕分辨率的布局是 5-6 个小磁贴的宽度。Suggested layout to work with most screen resolutions is 5-6 small tiles wide.
  • 所有仪表板磁贴应具有适当的标题/副标题。All dashboard tiles should have appropriate titles/subtitles.
  • 考虑在仪表板中为不同的方案分组(垂直或水平)。Consider groupings in the dashboard for different scenarios, either vertically or horizontally.

示例数据Sample data

属于应用创建阶段的模板应用将缓存数据作为应用的一部分包装在工作区中:Template apps, as part of the app creation stage, wraps the cache data in the workspace as part of the app:

  • 可便于安装人员在连接数据之前了解应用的功能和用途。Allows the installer to understand the functionality and purpose of the app before connecting data.
  • 创造促使安装人员进一步探索应用功能的体验,从而促成连接应用数据集。Creates an experience that drives the installer to further explore app capabilities, which leads to connecting the app dataset.

建议在创建应用前获得优质示例数据,We recommend having quality sample data before creating the app. 以确保应用报表和仪表板都填充有数据。ensure the app report and dashboards are populated with data.

发布到 AppSourcePublishing on AppSource

模板应用可以发布到 AppSource。将应用提交到 AppSource 前,请遵循以下指南:Template apps can be published on AppSource, follow these guidelines before submitting your app to AppSource:

  • 确保你创建的模板应用包含有吸引力的示例数据,有助于安装人员了解应用的用途(空的报表和仪表板不会获准)。Make sure you create a template app with engaging sample data that can help the installer understand what the app can do (empty report & dashboard aren't approved). 模板应用支持仅包含示例数据的应用,请务必选中静态应用复选框。Template apps support sample data only apps, make sure to check the static app checkbox. 了解详细信息Learn more
  • 制定可供验证团队遵循的说明,其中包括连接到数据所需的凭据和参数。Have instruction for the validation team to follow which includes credentials and parameters that are required to connect to data.
  • 应用必须在 Power BI 中和 CPP 产品/服务上添加“应用”图标。Application must include an App icon in Power BI and on your CPP offer. 了解详细信息Learn more
  • 已配置登陆页面。Landing page configured. 了解详细信息Learn more
  • 务必遵循 合作伙伴中心 -> Power BI 应用产品/服务文档中的指南。Make sure to follow the documentation on Partner center -> Power BI App offer.
  • 如果仪表板是应用的一部分,请确保仪表板不为空。In case a dashboard is part of your app, make sure it's not empty.
  • 提交前,先使用应用链接安装应用,以确保你能连接数据集,且应用体验符合预期。Install the app using the app link before submitting it, make sure you can connect the dataset and the app experience is as you planned.
  • 将 pbix 上传到模板工作区前,请先务必卸载任何不必要的连接。Before uploading pbix into the template workspace, make sure to unload any unnecessary connections.
  • 遵循 Power BI 报表和视觉对象设计最佳做法,以实现对用户的最大影响,并获得分发批准。Follow Power BI Best design practices for reports and visuals to achieve maximum impact on your users and getting approved for distribution.

在 AppSource 上发布模板应用后,请考虑创建一个可从网站下载到以下位置的下载链接:After publishing the template app on AppSource, consider creating a download link from your website to either:

  • AppSource 下载页面(可以公开查看),请从 AppSource 页面获取链接。AppSource download page - can be viewed by publicly, get the link from your AppSource page.
  • Power BI - 可供 Power BI 用户查看。Power BI - Can be viewed by a Power BI user.

若要将用户重定向到 Power BI 中的应用下载链接,请参阅以下代码示例:GitHub 存储库In order to redirect a user to the app's download link in Power BI see the following code example: GitHub repo.

应用下载链接App Download link

后续步骤Next steps

什么是 Power BI 模板应用?What are Power BI template apps?