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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Power BI : Rscript as a data source

Hi ,

It would be great if anyone can help me on this :

I want to fetch data from sales force (few tables row count) ,For that I am usng R script (SOQL) as a data source in power BI.

When I try to run the script which is given below ,it is throwing an error

 

start_time <- Sys.time()

library(salesforcer)
library(dplyr, warn.conflicts = FALSE)
library(httpuv)
library(tidyverse)
library(readr)
library(odbc)
library(DBI)
library(dplyr)
library(stringr)
library(tidyr)
library(tidytext)
library(textdata)
library(tm)
library(purrr)
library(tibble)
library(openxlsx)
library(taskscheduleR)

#sf_auth()

username <- "nmurphy@analytics.demo" # normal email/sflogin
password <- "YOUR_SF_PASSWORD+YOUR_TOKEN"
instanceURL <- "https://login.salesforce.com/"

# Account table count
# ---------------------------------------------------
SFDC_Account_Daily <- sf_query(soql = "SELECT COUNT (Id),
day_in_month(CreatedDate),
calendar_month(CreatedDate)
FROM Account
WHERE IsDeleted = False AND CreatedDate=THIS_MONTH
GROUP BY day_in_month(CreatedDate),
calendar_month(CreatedDate)")

# Drop the attributes Column
SFDC_Account_Daily <- within(SFDC_Account_Daily, rm(attributes.type))
# Rename columns to meaningful names
SFDC_Account_Daily <- SFDC_Account_Daily %>%
rename(
Count = expr0,
Date = expr1,
Month = expr2)
# ---------------------------------------------------
# Account table count end


# SD_Project table count
# ---------------------------------------------------
SFDC_SD_Project_Daily <- sf_query(soql = "SELECT COUNT (Id),
day_in_month(CreatedDate),
calendar_month(CreatedDate)
FROM pse__Proj__c
WHERE IsDeleted = False AND CreatedDate=THIS_MONTH
GROUP BY day_in_month(CreatedDate),
calendar_month(CreatedDate)")

# Drop the attributes Column
SFDC_SD_Project_Daily <- within(SFDC_SD_Project_Daily, rm(attributes.type))
# Rename columns to meaningful names
SFDC_SD_Project_Daily <- SFDC_SD_Project_Daily %>%
rename(
Count = expr0,
Date = expr1,
Month = expr2)

 

Error : 

chithra_0-1668076612837.png

 

2 REPLIES 2
Adel
Helper III
Helper III

i think you are complicating this for yourself, one solution to this will be to use some tool like windsor.ai to get data from salesforce to power bi.
https://windsor.ai/microsoft-power-bi-salesforce-report-dashboard-template/

Anonymous
Not applicable

Thank you for your update .We wont be able to use external application to fetch the data.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors