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 ...
随机推荐
- 在使用 百度编辑器 Ueditor 时,不能进入 Controller 相应的 Action 的处理方法
如果在前端的页面中使用了 Ueditor 编辑器,那么在提交表单数据时,将不会执行 期望的 Controller 中的 Action ,造成这样的原因是: 在 MVC 4 的框架中,当前端页面需要提交 ...
- c# 了解委托
public delegate void aHandler(string text); public class A1 { public void Print(string txt) { Consol ...
- 5 Ways to Learn and Remember Absolutely Anything
http://www.inc.com/quora/5-ways-to-learn-and-remember-absolutely-anything.html Start too early on th ...
- IP配置
1: #vi /etc/sysconfig/network-scripts/ifcfg-eth0 2: 实验环境-网络设置 公司域网: IP=162.168.16.0/24 netmask=255.2 ...
- hdu2072
注意输入全是0的情况. #include <stdio.h> #include <string.h> #include <algorithm> using name ...
- Android OptionMenu
1.Java package com.fish.helloworld; import android.app.Activity; import android.content.Context; imp ...
- 021ARM处理器工作模式
1.User模式:usr,普通应用程序运行的模式: 2.FIQ模式:fiq,快速中断模式,当一个程序正在运行时,突然产生一个中断,而且这种中断属于快速中断,那么将进入快速中断模式下运行: 3.IRQ模 ...
- php mkdir函数
if(!is_dir($targetPath)){mkdir($targetPath, 0700); } is_dir 判断目录是否存在 mkdir 不能创建多级目录
- Linux 常用ps命令
(1)查看系统所有进程: 标准格式: ps -e ps -ef ps -eF ps -ely BSD格式: ...
- 使用C#中JavaScriptSerializer类将对象转换为Json格式数据
将对象转换为json格式字符串: private JavaScriptSerializer serializer = new JavaScriptSerializer(); protected voi ...