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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
chithra
Regular Visitor

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/

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors