Tutorial: Facebook analytics using Power BI Desktop
In this tutorial you learn how to import and visualize data from Facebook. During the tutorial you'll learn how to connect to a specific Facebook page (the Power BI page), apply data transformation steps, and create some visualizations.
Here are the steps you'll take:
Task 1: Connect to a Facebook Page
Task 2: Create visualizations using the Report view
- Step 1: Create a Treemap visualization
Task 3: Shape data in the Query view
- Step 1: Split the date-time column into two
- Step 2: Add an aggregate value from a related table
Task 4: Create additional visualizations using the Report view
- Step 1: Load the query to your report
- Step 2: Create a Line chart and a Bar chart
Task 1: Connect to a Facebook page
In this task you import data from the Microsoft Power BI Facebooksite (here's the URL: https://www.facebook.com/microsoftbi ).
Anyone can connect to that page, and follow these steps - no special credentials (other than your own Facebook account, which you use in this step) are required.
In the Getting Started dialog or in the Home ribbon tab, select Get Data.
The Get Data dialog appears, letting you select from all sorts of data sources. Select Facebook from the Other group.
When you select Connect, a dialog appears to alert you to the risks of using a third-party service.
When you select Continue, the Facebook dialog box appears where you can paste the page name (microsoftbi) into the Username text box. Select Posts from the Connection drop down.
Click OK.
When prompted for credentials, sign in using your Facebook account and allow Power BI access through your account.
After establishing a connection to the page, you will see the data being loaded in the model.
From there, Query Editor displays the data. Query Editor is part of Power BI Desktop, but loads in a separate window, and is where you perform all your transformations on your data connections.
When your data is how you want it, you can load it into Power BI Desktop. Select Load & Close from the Home ribbon.
You'll see a dialog that displays the progress of loading the data into the Power BI Desktop data model.
Once loaded, you’ll be taken to the Report view where the columns from the table are listed in the Field list on the right.
Task 2: Create visualizations using the Report view
Now that you have landed the data from the page, you can quickly and easily gain insights about your data, using visualizations.
Step 1: Create a Treemap visualization
Creating a visualization is easy, we just drag a field from the Field list and drop it on the Report canvas.
Drag the type field onto the Report canvas. Power BI Desktop creates a new visualization in the Report canvas. Next, drag type from Fields (the same field you just dragged onto the Report canvas) onto the Value area to create a Bar visualization.
We can easily change the type of visualization by selecting a different icon from the Visualization pane. Let's change the type to a Treemap by selecting its icon from Visualizations, as shown in the following image.
Next, let's add a legend, then change the color of a data point. Select the Format icon in the Visualizations pane; the Format icon looks like a paintbrush.
When you select the down arrow next to Legend, the section expands to show how to customize the legend for the selected visualization. In this case, we made the following selections:
moved the Legend slider to On so a legend would appear
selected Right from the Legend Position drop-down
moved the Title slider to On as well, so a title for the legend will appear
typed in type for the title of the legend
In the following image, those settings are already made and reflected in the visualization.
Next, let's change the color of one of the data points. The link data point should be blue, so it's closer to the common color for hyperlinks.
Select the arrow next to Data Colors to expand that section. The data points are shown, with selection arrows beside each color that allows us to select a different color for each data point.
When you click on the color box down arrow beside any data point, a color selection dialog appears, letting you choose your color. In this case, we'll choose light blue.
That's better. In the following image, you can see how the color is applied to the data point in the visualization, and that the legend is also automatically updated, as is its color in the Data Colors section.
Task 3: Shape data in the table
Now that you have imported the table selected and you start to visualize it, you may notice you need to perform various data shaping and cleansing steps in order to get the most out of your data.
Step 1: Split the date-time column into two
In this step, you will split the created_time column to get both the date and time values. Whenever you're in Power BI Desktop and you want to modify an existing query, you need to launch Query Editor. To do that, select Edit Queries from the Home tab.
In the Query Editor grid, scroll to the right until you find the created_time column
Right-click a column header in the Query Preview grid, and click Split Column > By Delimiter to split the columns. Chose Custom in the delimiter drop down and enter “T” Note that this operation is also available in the Home ribbon tab, in the Manage Columns group.
Rename the created columns to created_date and created_time respectively.
Select the new column, created_time, **** and in the Query view ribbon, navigate to the Add Column tab and select Time>Hour under the From Date & Time group. This will add a new column that is only the hour component of the time.
Change the type of the new Hour column to Whole Number, by navigating to the Home tab and selecting the Data Type drop down or by right-clicking the column and selecting Transform>Whole Number.
Step 2: Add an aggregate value from a related table
In this step, you add the count of shares from the nested value so that you can use it in the visualizations.
Continue scrolling to the right until you see the shares column. The nested value indicates that we need to do another transform in order to get the actual values.
In the top right of the column header, select the icon to open the Expand/Aggregate builder. Select count and hit OK. This will add the count of the shares for each row in our table.
After the data loads, rename the column to shares by double clicking on the column name, right clicking the column or in the Query view ribbon, select Rename under the Transform tab and Any Column group.
Finally, change the type of the new shares column to Whole Number. With the column selected, the type can be changed by right-clicking the column and selecting Transform>Whole Number or **** by navigating to the Home tab and selecting the Data Type drop down or.
Query steps created
As you perform transformations in the Query view, query steps are created and listed in the Query Settings pane, in the APPLIED STEPS list. Each query step has a corresponding Query formula, also known as the "M" language.
Task | Query step | Formula |
Connect to a Facebook source | Source | Facebook.Graph ("https://graph.facebook.com/microsoftbi/posts") |
Split Columns to get the values you need | Split Column by Delimiter | Table.SplitColumn (Source,"created_time",Splitter.SplitTextByDelimiter("T"),{"created_time.1", "created_time.2"}) |
Change Type of the new columns (automatic step) | Changed Type | Table.TransformColumnTypes (#"Split Column by Delimiter",{{"created_time.1", type date}, {"created_time.2", type time}}) |
Rename **a column** | Renamed Columns | Table.RenameColumns (#"Changed Type",{{"created_time.1", "created_date"}, {"created_time.2", "created_time"}}) |
Insert **a column** | Inserted Hour | Table.AddColumn (#"Renamed Columns", "Hour", each Time.Hour([created_time]), type number) |
**Change Type ** | Changed Type1 | Table.TransformColumnTypes (#"Inserted Hour",{{"Hour", type text}}) |
Expand **values in a nested table** | Expand shares | Table.ExpandRecordColumn (#"Changed Type1", "shares", {"count"}, {"shares.count"}) |
Rename **the column** | Renamed Columns1 | Table.RenameColumns (#" Expand shares",{{"shares.count", "shares"}}) |
Change Type | Changed Type2 | Table.TransformColumnTypes (#"Renamed Columns1",{{"shares", Int64.Type}}) |
Task 4: Create additional visualizations using the Report view
Now that we have converted the data into the shape that we need for the rest of our analysis, we can load the resulting table into our Report and create additional visualizations.
Step 1: Load the query to your report
In order to load the query results to the report, we need to select Load & Close from Query Editor. This will load our changes into Power BI Desktop, and close Query Editor.
In Power BI Desktop, we need to make sure we're in Report view. Select the top icon from the left bar in Power BI Desktop.
Step 2: Create a Line chart and a Bar chart
In order to create a visualization, we can drag fields from the Field list and drop them in the Report canvas.
Drag the shares field onto the Report canvas, which creates a bar chart. Then drag created_date onto the chart, and Power BI Desktop changes the visualization to a Line Chart.
Next, drag the shares field and drop it in the Report canvas. Now drag the Hour field into the Axis section under the Field List.
We can easily change the type of visualization by clicking on a different icon in the Visualization pane. The arrow in the image below points to the Bar Chart icon.
Change the visualization type to Bar Chart.
The Bar Chart is created, but the axis isn't what we want - we want it sorted in the other direction (from high to low). Select the down arrow next to Y-Axis to expand that section. We need to change the type of axis from Continuous to Categorical, so it'll sort how we want it (the image below shows the axis before we make the selection - check out the subsequent image for how we want it to look).
That's better. And now we have three visualizations on this page, which we can size as we want to fill up the report page
.
As you can see, it's easy to customize visualizations in your report, so you can present the data in the way that you want. Power BI Desktop provides a seamless end-to-end experience from getting data from a wide range of data sources and shaping it to meet your analysis needs to visualizing this data in rich and interactive ways. Once your report is ready, you can upload it to Power BI and create dashboards based on it, which you can share with other Power BI users.
You can download the end result of this tutorial here
Tutorial: Facebook analytics using Power BI Desktop的更多相关文章
- Tutorial: Importing and analyzing data from a Web Page using Power BI Desktop
In this tutorial, you will learn how to import a table of data from a Web page and create a report t ...
- Pyramid Analytics宣布无缝集成BI Office和微软Power BI Desktop
全球领先的企业商业智能(BI)软件提供商Pyramid Analytics与微软联手,凭借完善的分析平台BI Office强化Power BI Desktop的个人生产力功能.新的“Publish t ...
- Q&A in Power BI service and Power BI Desktop
What is Q&A? Sometimes the fastest way to get an answer from your data is to ask a question usin ...
- Power BI官方视频(3) Power BI Desktop 8月份更新功能概述
Power BI Desktop 8月24日发布了更新版本.现将更新内容翻译整理如下,可以根据后面提供的链接下载最新版本使用. 1.主要功能更新 1.1 数据钻取支持在线版 以前的desktop中进行 ...
- Power BI官方视频(1) Power BI Desktop 7月份更新功能概述
2016年7月,Power BI Desktop进行了一些功能更新,提高整体的用户体验.同时也有一些新的和令人兴奋的功能.看看大概介绍,更新功能要点: 本文原文地址:Power BI官方视频(1) P ...
- Power BI官方视频(4) Power BI Desktop 2017年首次更新先睹为快
在过去的2016年,Power BI Desktop在功能上进行了很多改进和更新,产品迭代速度非常快,基本是每个月一个版本.过去的一年,我们期待的Power BI中国区服务已经可以在世纪互联购买和使用 ...
- 根据 Power BI Desktop(预览版)中的报表页创建工具提示
根据 Power BI Desktop 中创建的报表页,可创建直观丰富的报表工具提示,这些提示在你将鼠标悬停在视觉对象上时显示. 通过创建用作工具提示的报表页,使自定义工具提示包含视觉对象.图像以及在 ...
- Power BI Desktop 新年快乐!
新年快乐 2018年是Power BI 多产的一年!更新发布的功能就超过150多个,真是相当的强大! 为了庆祝这一成功的一年,Power BI官方团队制作了一个有趣的视频,展示他们对2018年最喜欢的 ...
- 在最新的Power BI Desktop中使用报表主题功能
报表主题的工作原理 Power BI Desktop中,增加了万众期待的报表主题色功能(预览),如下图: 要使用这个功能,请先在官网下载并安装最新版的Power BI Desktop.安装成功后在&q ...
随机推荐
- SQL:认识数据库约束
讲了关于数据库的很多内容,也讲了很多约束,对唯一和主键.核查和规则.外键约束很感兴趣. 一.唯一和主键(实体完整性) 区别: 数量:一张表只可以有一个主键约束,却可以有多个唯一约束. 是否空值:主键不 ...
- PAT1015. Reversible Primes
//题的理解是n在基数b中的的表示中,正序和逆序值都是素数,但是其实可直接判断n,因为n在b中的正常序列值就是再换成十进制就是n,但是不A:不知道为什么 用笨方法,先把n展开成b进制,正常计算其实是翻 ...
- 有联系的jQuery选择器
1.包含关系 2.相邻关系 //JavaScript$(document).ready(function () { $(".studentName + div").hide(); ...
- meta 标签属性(网站兼容与优化需要)
概要 标签提供关于HTML文档的元数据.元数据不会显示在页面上,但是对于机器是可读的.它可用于浏览器(如何显示内容或重新加载页面),搜索引擎(关键词),或其他 web 服务. —— W3School ...
- Windows phone 8 学习笔记(2) 数据文件操作(转)
Windows phone 8 应用用于数据文件存储访问的位置仅仅限于安装文件夹.本地文件夹(独立存储空间).媒体库和SD卡四个地方.本节主要讲解它们的用法以及相关限制性.另外包括本地数据库的使用方式 ...
- js怎样改变div的宽度
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- SQLserver2012 修改数据库架构
还原数据库以后,发现有一张表的架构不对,执行sql提示:对象名无效.
- php-resque学习笔记二(配置)
1:前提 系统:CentOS PHP版本:PHP7 安装目录:/usr/local/php php-resque 安装目录:/home/software/php-resque ...
- JavaScript API 设计原则
网+线下沙龙 | 移动APP模式创新:给你一个做APP的理由>> 好的 API 设计:在自描述的同时,达到抽象的目标. 设计良好的 API ,开发者可以快速上手,没必要经常抱着手册和文档, ...
- 软件工程 speedsnail 冲刺8
完成任务:蜗牛移动的界面调整,速度调整: 遇到问题: 问题1 进入关卡的开始蜗牛会跳一段距离 解决1 线程延迟3S: 明日任务: 划线实现挡板功能