Skip to content

Instantly share code, notes, and snippets.

@bruna-garcia
Created August 12, 2020 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruna-garcia/ad6d645e802422891a0f85e9928e7230 to your computer and use it in GitHub Desktop.
Save bruna-garcia/ad6d645e802422891a0f85e9928e7230 to your computer and use it in GitHub Desktop.
Connect your Google Sheets to Power BI with R Script
#Installing R packages
install.packages("googlesheets4")
install.packages("httpuv")
#Authenticating your Google Drive
library(googlesheets4)
gs4_auth(
email = gargle::gargle_oauth_email(),
path = NULL,
scopes = "https://www.googleapis.com/auth/spreadsheets",
cache = gargle::gargle_oauth_cache(),
use_oob = gargle::gargle_oob_default(),
token = NULL
)
#Inside Power BI, Get Data > Other > R Script
library(googlesheets4)
library(magrittr)
myGoogleSheets<-"INSERT GOOGLE SHEETS URL"
myGoogleSheets %>%
as_sheets_id() %>%
read_sheet(range = "INSERT RANGE") -> # The range must include the name of the specific Sheet, e.g.:"Sheet_1:A:Z"
NAME_YOUR_SHEET #This will appear as the name of your Power BI table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment