Analyze Facebook Groups with Power BI

Today I presented at Power BI Global User Group, and demonstrated how to import Facebook group posts into Power BI, analyze the group engagement, and run sentiment analysis on the comments.

Here is the YouTube Recording:

Watch the recording to learn how to create the report below.

Subscribe to DataChant to get the Power BI Template file Facebook Group Analytics.pbit which was used to prepare the report aboveand to get access to other great resources.

Subscribe To DataChant

Join our mailing list to receive exclusive content that was used in the preparation of this article.

Thank you for subscribing to DataChant. An email will be sent to you shortly with more details.

You can also download the template here. When you open the template, you will be prompted to provide an API key from Microsoft Cognitive Services (Find one here).

api-key

You may need to be a member of the Global Power BI user group for the refresh to work, or change the query to import data from a public group, or a group you are a member of.

If you encounter a Formula.Firewall error, please enable Fast Combine. Read here how to enable it.

desktop_privacylevels1

Enjoy this session
Gil

18 comments

  1. Pingback: Facebook & Sentiment Analysis by Gil Raviv – Global & Virtual Power BI User Group

  2. Dan DoghiReply

    hello. thanks for sharing this information. I tried for my CLOSED group and the table was generated empty; I guess the feature works only for OPEN groups?

  3. Marc VReply

    Hi Gil,

    I might have missed it in your video, but is it possbile to get data about the countries/cities from your members in a Facebook Group?

    Thank you.

  4. AnonymousReply

    thanks for your answer; I am admin, and the result is the one I mentioned, unfortunately.

  5. Vivek RReply

    Hi – Thank you for the explaining the procedure. I am however not able to complete the process as getting the following error post running the process of custom function:

    An error occurred in the ‘’ query. DataSource.Error: Web.Contents failed to get contents from ‘https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment’ (400): Bad Request
    Details:
    DataSourceKind=Web
    DataSourcePath=https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment

    Please help.

    • Gil Raviv Post authorReply

      Hi Vivek,
      The error is usually triggered if your “id” column has duplicate values, or your “text” column has empty values.

  6. AnonymousReply

    I am having the same problem for a closed group in which I am admin. I am able to get back that some minimal information about the group such as the name, privacy level, connections, and the id. Has anyone had any luck with this yet? Or is this how it would be returned by the graph API even without Power BI?

  7. AnonymousReply

    Hi Gil,
    Your detailed explanation is highly appreciated. Many thanks.
    I’m having the same problem as posted by Vivek R, even after removing duplicates id and blank texts:
    ‘’ query. DataSource.Error: Web.Contents failed to get contents from ‘https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment’ (400): Bad Request
    Details:
    DataSourceKind=Web
    DataSourcePath=https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment”

    Any idea as how to proceed?
    Can this be related to microsoft cognitive upgraded version?

    Thanks for your help

    • Gil Raviv Post authorReply

      Hi Ofer,
      Can you confirm that you used the columns “text” and “id”? Using different column names will return this error.
      Please share the M expression, if you use the correct column names, and still have the error.

  8. AnonymousReply

    Hi Gil,
    “id” and “text” are indeed my columns name. I still get this error….
    the code for GetSentimentResults is a copy-paste of your code
    The following is the code under the “Comment Sentiment” query which I’m trying to create (with the Invoke custom Function:

    Thanks.

    let
    Source = Comments,
    #”Removed Other Columns” = Table.SelectColumns(Source,{“comments.message”, “comments.id”}),
    #”Renamed Columns” = Table.RenameColumns(#”Removed Other Columns”,{{“comments.id”, “id”}, {“comments.message”, “text”}}),
    #”Reordered Columns” = Table.ReorderColumns(#”Renamed Columns”,{“id”, “text”}),
    #”Added Index” = Table.AddIndexColumn(#”Reordered Columns”, “Index”, 0, 1),
    #”Integer-Divided Column” = Table.TransformColumns(#”Added Index”, {{“Index”, each Number.IntegerDivide(_, 2000), Int64.Type}}),
    #”Grouped Rows” = Table.Group(#”Integer-Divided Column”, {“Index”}, {{“data”, each _, type table}}),
    #”Invoked Custom Function” = Table.AddColumn(#”Grouped Rows”, “GetSentimentResults”, each GetSentimentResults([data]))
    in
    #”Invoked Custom Function”

    • Gil Raviv Post authorReply

      Thank you for sharing. Can you edit the Integer Divide step from 2000 to 1000? This should fix the issue. The API doesn’t support sending 2000 messages in a single API call.

  9. Pingback: Analyze Public Facebook Groups in #PowerBI - DataChant

Leave a Reply