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.

  1. In the Getting Started dialog or in the Home ribbon tab, select Get Data.

  2. 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.

  3. 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.

  4. Click OK.

  5. 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.

  1. In the Query Editor grid, scroll to the right until you find the created_time column

  2. 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.

  3. Rename the created columns to created_date and created_time respectively.

  4. 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.

  5. 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.

  1. 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.

  2. 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.

  3. 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.

  1. 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.

  2. 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.

  3. 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.

  4. Change the visualization type to Bar Chart.

  5. 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的更多相关文章

  1. 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 ...

  2. Pyramid Analytics宣布无缝集成BI Office和微软Power BI Desktop

    全球领先的企业商业智能(BI)软件提供商Pyramid Analytics与微软联手,凭借完善的分析平台BI Office强化Power BI Desktop的个人生产力功能.新的“Publish t ...

  3. 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 ...

  4. Power BI官方视频(3) Power BI Desktop 8月份更新功能概述

    Power BI Desktop 8月24日发布了更新版本.现将更新内容翻译整理如下,可以根据后面提供的链接下载最新版本使用. 1.主要功能更新 1.1 数据钻取支持在线版 以前的desktop中进行 ...

  5. Power BI官方视频(1) Power BI Desktop 7月份更新功能概述

    2016年7月,Power BI Desktop进行了一些功能更新,提高整体的用户体验.同时也有一些新的和令人兴奋的功能.看看大概介绍,更新功能要点: 本文原文地址:Power BI官方视频(1) P ...

  6. Power BI官方视频(4) Power BI Desktop 2017年首次更新先睹为快

    在过去的2016年,Power BI Desktop在功能上进行了很多改进和更新,产品迭代速度非常快,基本是每个月一个版本.过去的一年,我们期待的Power BI中国区服务已经可以在世纪互联购买和使用 ...

  7. 根据 Power BI Desktop(预览版)中的报表页创建工具提示

    根据 Power BI Desktop 中创建的报表页,可创建直观丰富的报表工具提示,这些提示在你将鼠标悬停在视觉对象上时显示. 通过创建用作工具提示的报表页,使自定义工具提示包含视觉对象.图像以及在 ...

  8. Power BI Desktop 新年快乐!

    新年快乐 2018年是Power BI 多产的一年!更新发布的功能就超过150多个,真是相当的强大! 为了庆祝这一成功的一年,Power BI官方团队制作了一个有趣的视频,展示他们对2018年最喜欢的 ...

  9. 在最新的Power BI Desktop中使用报表主题功能

    报表主题的工作原理 Power BI Desktop中,增加了万众期待的报表主题色功能(预览),如下图: 要使用这个功能,请先在官网下载并安装最新版的Power BI Desktop.安装成功后在&q ...

随机推荐

  1. 恶心的Oracle的if else if...

    出处:http://blog.sina.com.cn/s/blog_407d47e60100d8ig.html 前段时间写Oracle存储过程就遇到问题.原来写成这样if 1=2 then  null ...

  2. 学习记录 java session保存用户登录

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  3. android + javascript 相互通信实例分析

    1.  AndroidManifest.xml中必须使用许可 "android.permission.INTERNET", 否则会出Web page not available错误 ...

  4. Hyper-V下安装Ossim系统

    WindowsServer2008Hyper-V下安装Ossim系统 背景:很多朋友在用Hyper-v安装Linux的时候总是抱怨速度很慢,而且装好了系统无法识别网卡,可实际上针对网卡的问题本文提出了 ...

  5. jenkins smtp设置调试

  6. boost实现串口通信(一):小试牛刀

    /************************************************************************/ /* 功能:boost实现串口通信类 */ /* ...

  7. 1.2Android系统移植的主要工作

    1.Android移植分为两部分:应用移植和系统移植: 2.应用移植:指将第四层的应用程序一直到某一特定硬件平台上. (1)为保证应用程序能在新的平台上正常运行,需要对源代码就行一些修改,因为硬件平台 ...

  8. javaSE27天学习目录

      第一阶段(java基础知识) 计算机基础知识 Java开发环境的搭建和应用 机制转换 有符号数据表示法(原码.反码.补码) Java语句基础(关键字.标识符.注释.常量.变量.数据类型.运算符) ...

  9. Permission Lists Assigned to a User

    SQL that I find useful in many occasions. It will return a list of permissions that are assigned to ...

  10. js数组的内部实现,迭代器,生成器和内包

    js内部实现 在js以外的很多语言中,数组将会隐式占用一段连续的内存空间.这种隐式的内部实现,使得高效的内存使用及高速的元素方法称为可能,而 在javascript中,数组实体是一个对象,所以通常的实 ...