Created
August 12, 2020 22:23
-
-
Save bruna-garcia/ad6d645e802422891a0f85e9928e7230 to your computer and use it in GitHub Desktop.
Connect your Google Sheets to Power BI with R Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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