What Power BI users need to know about R
Nico Jacobs 1996 – 2004: Researcher @ KULeuven (Machine learning) 2004 – now: SQL Server, Power BI and Cortana Intelligence Trainer @ U2U SQLWaldorf (twitter/linkedin)
Power BI flow Load data Transform Model data Report
R in Power BI prerequisites Power BI Desktop must be installed from https://powerbi.microsoft.com/en-us/desktop/ We must have R installed as well In Power BI Desktop File Options and Settings Options R Scripting we can specify which local R installation we want to use Both the Microsoft R Open, Microsoft R Client, Microsoft R Server and CRAN R distributions are supported
R as a source Twitter data Random data https://www.google.be/search?q=r+make+twitter+data+accessible+for+research&oq=r+make+twitter+data+accessible+for+research
Adding an R data source In Power BI Desktop from the Home ribbon select Get Data Select the option More From the Other group select R Script and click connect
Providing the R script The Execute R Script dialog has no Intellisense, syntax coloring or other support for writing the code Prefer writing the script in R Tools for Visual Studio, R Studio or other R editor, then paste it into this window
Navigator In the navigator we see all variables holding data frames By clicking on the name we get a preview of the data set We can select which data set we want to load or edit
Query editor In the editor we can use Power Query to modify the data set produced by R By clicking the gear icon next to source we can change the R script as well
R as a transformation Fuzzy matching Outlier detection
R charts Histogram ggplot
R visualizations Power BI desktop has many data visualizations Both build-in and add-on One of the build in visualizations is the R rendering Just as the R source this depends on an R version to be installed Not part of Power BI Desktop installation
Create R visualization First create a Power BI Desktop file with one or more data sources These can be any data sources supported by Power BI: not only R sources Then add a report in Power BI Desktop In the visualizations dialog select the R visualization
Configuring the R visualization 3: run R script 1: select fields 2: provide R script
Visualization R script Power BI Desktop automatically creates a data frame with all the selected fields These fields can come from more than one source table By default the values are not aggregated and not filtered, but this can be changed as with any Power BI visualization Then all distinct values are taken Add row number if you need all rows Then we can write our own script When using libraries, make sure these are installed in your R distribution
Visualization interaction When we interact with regular Power Bi visualizations, these will filter our R visualization But not the other way round
Just like Jimi Hendrix … We love to get feedback Please complete the session feedback forms
SQLBits - It's all about the community... Please visit Community Corner, we are trying this year to get more people to learn about the SQL Community, equally if you would be happy to visit the community corner we’d really appreciate it.
@SQLWaldorf