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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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