从洞察到快速行动展示

  • 版本 :2023.1(当前版本)

从洞察到快速行动展示

Power BI 游乐场的从洞察到快速行动演示了一个基于实时分析创建有意义的客户活动的应用程序。用户可以切片和过滤 Power BI 嵌入式报告数据以发现见解,然后立即从报告中配置和启动客户折扣或优惠券活动。

此展示展示了应用程序如何使用以下命令:

  • 扩展菜单命令API ,用于向报表添加自定义命令和菜单项。

  • 事件处理以在报表事件和应用程序代码之间进行通信。

  • 用于导出报表视觉对象的基础数据的exportData API 。

从洞察到快速行动展示体验

Contoso 是一家虚构的销售公司,它使用从见解到快速行动展示柜生成见解并直接从 Power BI 嵌入式报告中启动活动。嵌入式报告按客户名称和地区、购买类别、自上次购买以来的天数和消费金额显示客户的购买情况。

该报告具有表格、柱形图和圆环图可视化效果,以及多种切片、过滤和排序机制。对于此报告,Contoso 最感兴趣的是过去 30 天的 500 美元至 799 美元的高端购买,因此报告会加载应用的切片器范围。

屏幕截图显示了对行动展示的见解。

产生洞察力

要深入了解销售结果,报表用户可以通过在下拉列表、可视化效果和切片器中选择特定值和范围来进一步过滤或切片数据。例如,专业服务的销售经理选择了几个不同的区域,并意识到虽然专业服务类别的总支出最高,但它在 MEA、英国和美国地区的支出最低,并且在 LATAM 没有购买或加拿大。

屏幕截图显示了在圆环图中选择的美国区域,它突出显示了美国支出数据与“按最新购买类别划分的总支出”条形图中的总支出相比。

创建一个活动

销售经理决定向加拿大、拉丁美洲、中东非洲、英国和美国客户推广专业服务销售。要随时使用当前客户列表开始营销活动,销售经理可以选择创建营销活动按钮,或从客户表视觉对象的更多选项( ... ) 菜单中选择开始营销活动。

显示“创建活动”按钮的屏幕截图。

屏幕截图显示了表可视化更多选项菜单中的开始市场活动选项。

创建目标客户列表

报表用户可以使用报表下拉列表、可视化效果和切片器将客户列表缩小到目标收件人。在这种情况下,销售经理从Region下拉列表中选择CanadaLATAMMEAUKUnited States ,并且客户表现在仅列出来自这些地区的客户。客户列表准备就绪后,销售经理选择创建活动

显示区域下拉列表的屏幕截图,其中选择了多个区域,客户列表仅显示来自这些区域的客户。

创建折扣活动

Campaign 分发列表弹出窗口打开,列出目标收件人的姓名和联系信息,并提供发送折扣发送优惠券的选项。销售经理选择发送折扣

显示带有活动分发联系人列表和发送折扣和发送优惠券按钮的对话框的屏幕截图。

在“将折扣发送到分发列表”对话框中,销售经理编写了一条消息,为目标客户提供 10% 的 Contoso 专业服务折扣,然后选择“发送” 。

显示消息文本框和发送按钮的屏幕截图。

该应用程序将折扣优惠电子邮件发送到通讯组列表,并显示已发送通知。

销售经理还可以通过在分发列表屏幕上选择发送优惠券来向客户发送优惠券。

Go from insights to quick action showcase code

The code for implementing the showcase is in the PowerBI-Embedded-Showcases GitHub repository.

  • The application HTML code builds the embedded report container and elements, dialog boxes, text fields, and buttons.

  • The report JavaScript code embeds the report and defines all the visualization interactions, data exports, and button handling functions.

Add the campaign command to the report

The report embedConfiguration uses the extend menu command API to add a campaign command to the report, which appears at the top of the More options menu of the table visual.

Javascript复制

let config = {
...
settings: {
...
extensions: [
{ command: { name: "campaign", title: "Start campaign", icon: base64Icon, selector: { $schema: "http://powerbi.com/product/schema#visualSelector", visualName: tableVisualGuid
}, extend: { visualOptionsMenu: { title: "Start campaign", menuLocation: models.MenuLocation.Top,
}
}
}
},
...
}
}

Handle the Start campaign command

以下代码处理命令的commandTriggered事件campaign。该代码侦听Start campaign菜单项选择事件,并从表视觉发送当前过滤的客户列表数据。

Javascript复制

// Adding onClick listener for the custom menu in the table visual in the reportreportShowcaseState.report.on("commandTriggered", 
async function (event) { if (event.detail.command === "campaign") {
// Populate data according to the current filters on the table visual
const result = await tableVisual.exportData(models.ExportDataType.Underlying);
handleExportData(result);
onStartCampaignClicked();
}
});

处理“创建广告系列”按钮的点击

以下代码处理创建活动按钮单击事件。该代码侦听创建活动按钮选择事件,并从视觉表发送当前过滤的客户列表数据。

Javascript复制

// Adding onClick listener for the button in the reportreportShowcaseState.report.on("buttonClicked", async function () {    
// Populate data according to the current filters on the table visual
const result = await tableVisual.exportData(models.ExportDataType.Underlying);
handleExportData(result);
onStartCampaignClicked();
});