'Power BI Report using Facebook real time data
I want to show the insights(page view, comments, posts, etc) data of my Facebook page in a Power BI dashboard, that is embedded into my web-page, I am able to show the dummy report by downloading the Facebook page CSV report. If I have to real-time update the dashboard what is the procedure for that.
Solution 1:[1]
there are at least two options:
- Connector
- API
Connector
At this very moment there might be an issue connecting Power BI to Facebook but in general you should be able to use the built-in connector.
Please note that with the connector, once your report is published in Power BI Service it will not refresh data in real-time, instead in semi-real time. For example, you can define to refresh the data source up to 8 times a day (using Pro license) or even more if you have Enterprise Premium Capacity.
API
Instead, if you really need to deal with real-time data the alternative is using the API offered in the real-time streaming service of Power BI.
Solution 2:[2]
There are many ways you can do this I will list a few below :
API URL: which you can connect directly to power bi but it has it's issues such as (API calls limit, Won't be able to show historical data, take a lot of time to refresh)
Using the API, you can create an automated data pipeline :
import pyodbc import json import requests import pandas as pd import sqlalchemy import urllib
Create a JSON file and put there your credentials, then get the path. You should change the path i consigned by your own.
path_to_json='CreatedJasonfile'
with open(path_to_json,'r') as handler:
info = json.load(handler)
sql server parameters (put here your server and database names, you can put them into your JSON file)
user = info['user']
pwd = info ['password']
server = info ['server']
db = info['db']
Try:
conn = urllib.parse.quote_plus('DRIVER={ODBC Driver 17 for SQL
Server};SERVER='+server+';DATABASE='+db+';UID='+user+';PWD='+pwd)
engine = sqlalchemy.create_engine('mssql+pyodbc:///?odbc_connect=
{}'.format(conn))
print('connection successfull')
except:
print('error when trying to connect')
Parameters for the Windsor Connector
date_p='last_7d'
fields='&fields=date,campaign,clicks,spend,device'
url=info['url']+date_p+fields
Delete existing data
with engine.begin() as conn:
conn.execute(sqlalchemy.text("TRUNCATE TABLE BING_DATA"))
Inserting data in SQL Table
df.to_sql("FACEBOOK_DATA",engine,if_exists="append",index=False)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Seymour |
| Solution 2 | Kai - Kazuya Ito |
