Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
rc225225
New Member

Getting Facebook likes, comments and shares count

Hi all, 

 

I work in media and was wondering how I would be able to import Facebook data and be able to get the likes, comments and shares count for individual page posts. 

 

Have also tried this in power query in Excel 2016 but there seems to be a bit of a learning curve and I can't figure it out. Any help would be appreciated. 

 

Thanks 🙂

13 REPLIES 13
rc225225
New Member

Thanks @vasim07 that's what I suspected it was - good to have someone else with more expertise confirm this. However, I guess the main problem is the aggregation part - seems to rely heavily on the FB graph which is very very slow - guess there isn't a faster way to do this? 

 

@itchyeyeballs your problem is because the page you are trying to call from has too many posts - and I would guess that Facebook has a limitation as to how much data you can call in a single query. 

 

Here's what I've done as a workaround - first of all when you pick what kind of data you'd like to get from Facebook, pick 'Statuses' instead of 'Posts'. Usually that does the trick and you'll be able to get some data first. Then once the window pops up you click "Edit". 

 

Clicking edit will bring up the query. You then select "Advanced Editor" in which a pop up will appear with some code. Change to the following format:

 

This is the original format:

 

let
Source = Facebook.Graph("https://graph.facebook.com/v2.2/PAGENAMEHERE/statuses")
in
Source

--------

Now the changes you have to make:

1. Change 'statuses' at the end to 'posts' - because you want posts.

2. You will need to set a limit as to how much data you are pulling from Facebook, so add the following after statuses: ?limit=100

The number 100 is quite arbitrary but basically adjust it until you are able to pull data. 

 

Looks like this:

let
Source = Facebook.Graph("https://graph.facebook.com/v2.2/PAGENAMEHERE/statuses?limit=100")
in
Source

 

If you wish, you can even set some date parameters so the system will only pull in posts with the limit and between the dates you set:

let
Source = Facebook.Graph("https://graph.facebook.com/v2.2/PAGENAMEHERE/statuses?limit=100&since=2012-10-20&until=2012-12-31")
in
Source

 

 

This should solve your problem with the errors.

 

Meanwhile I'm still waiting for the FB graph to finish aggregating..sigh..there's got to be a better and faster way..

 

 

 

 

I got it to run in the end although its a bit flakey and falls over alot, refreshing the query seems to do the trick but thanks for the suggested workaround.

 

The number of posts in the page I'm looking at was only about 800 which doesn't seem a lot, asside from the unexpected error I also sometimes get an error asking me to reduce amount of data requested, again a refresh resolves.

 

The whole process It is very slow but I guess thats how facebook want it. Things seem to have improved a bit now its no longer lunch time, I guess FB throttle the API at busy times.

Yeah - still trying to justify the value of doing this. At the very least this query is able to populate all the posts easily so if I were to do it by hand that already saves a bit of the work. 

 

It is automation, but a very slow one at that. I was hoping for a faster way. Oh well - maybe we'll see better solutions down the road.

What do you mean by the FaceBook fields in the Power BI such as:

Caption

Id

Description

created_time

Icon

Is_expired

Is_hidden

Link

Message

Name

Object_id

Picture

Source

Status_type

Story

Type

Updated_time
?

I cannot find any information in the internet. Help me please.

vasim07
Helper I
Helper I

Maybe this might help.

@vasim07 - good stuff solves the issue I was having.

 

New problem for me is that trying to import data for entities with larger amounts of data causes an unexpected error, for example MicrosoftBI works but MicrosoftUK doesn't

 

Capture.GIF

@itchyeyeballs Not sure, MicrosoftUK worked for me. 676 Rows populated.

 

Capture.PNG

rc225225
New Member

Thanks for the help both - but it still doesn't solve the problem. 

 

SharedCount is for external webpages - not for posts within the Facebook platform. 

 

Again I'm looking for just a number count of the Likes, comments and shares so I can pull up some quick competitor analysis without having to do everything by hand. 

 

Anyone else who knows how to do this please let me know, thanks 🙂

djnww
Impactful Individual
Impactful Individual

Hi @rc225225,

 

I was actually analysing facebook data from our company site when I read your post 🙂

 

1. Within PowerBI Desktop, click on Get Data

2. Scroll down and select 'Facebook'

3. A message will pop up warning you that you will access a 3rd party site. Just click on 'continue'

4. For the username, enter the name of the Facebook Page. For instance, Microsoft's Facebook page is 'www.facebook.com/Microsoft'. The name in this instance is 'Microsoft'

5. Under connection, select 'Posts'.

6. You will be asked to enter your credentials, which is your actual Facebook login details.

 

I was analysing comments and posts. I'm not sure if Likes are available.

 

Cheers,

Daniel

 

 

Thanks for your help - what I was looking for is not necessarily the posts, but just the data. 

 

eg. Post 1 may have 100 likes, 25 shares and 56 comments. 

 

I would then take the total of these and divide it by a certain percentage of the fanbase to get an overall feel for how competitor content performs. 

Following the tutorial here - https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-tutorial-facebook-analytics/

 

I can only figure out how to pick up likes or comments from a single specified entity (all comments made by one user for example), there doesn't seem to be a way to pick up all likes on specific pages or posts.

 

I've probably missed something but It looks like you will have to manually utilise the insights element of the graph API - https://developers.facebook.com/docs/graph-api/reference/v2.5/insights or purchase a third party solution

ashishrj
Power Participant
Power Participant

@rc225225 An old post of mine on a blog given here. Might be helpful for you!

kazlik
Helper II
Helper II

If not too many you can use a service like SharedCount and their API to get FB counts. I use an input file with many URLs and call their free API in Excel and load the counts.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.