Data Smoothing with Splines
Description
Smoothing helps you to better visualize and understand noisy data
Prerequisites (The sample .pbix files will not work without these prerequites completed)
1. Install R Engine
Power BI Desktop does not include, deploy or install the R engine. To run R scripts in Power BI Desktop, you must separately installR on your local computer. You can download and install R for free from many locations, including the Revolution Open download page, and the CRAN Repository.
2. Install the required R packages.
Download the R script attached to this message and run it to install all required packages on your local machine.
Required R packages:
graphins, spline, scales
Tested on:
CRAN 3.3.1, MRO 3.3.0, powerbi.com
Legal Disclaimers:
Terms of Service and Third Party Programs.
8 Replies
- jdt008Advocate II
We love this visual. How should the script read if my dates are formatted as mm/dd/yyyy?
Thanks
- boefratyMicrosoft Employee
Hi, sorry for the delay in reply.
The X column is of type "numeric". You can convert "date" type to "numeric" in Power Query. Next you need to take care of X-axis ticks labels, to be formatted as you want.
I did something similar in
https://community.powerbi.com/t5/R-Script-Showcase/ARIMA-forecasting/m-p/124237Please have a look at the R code. If you still have trouble with it, you are welcome to send me the PBIX
- AnonymousNot applicable
Been looking at this visualization lately as I need to plot some datapoints and need to add regression lines. I'm plotting revenue/sales per day, and using the date as the category/legend. However, I need one line for each of the days, instead of one for all the data points.
How much work am I looking at doing smoething like this in R?
- ropebenderFrequent Visitor
I have a couple of visuals I want to use from R, but when I try to load this visual (and others) I am having issues trying to install the needed libraries I uninstalled the current version or R (3.5.1) and installed the version given in most all the visualizations in this section (3.3.1), but still I can't load most of the required libraries.
You say the visualization you require requires
Required R packages:
graphins, spline, scales
I can load scales, spline is not available for 3.3.1, but I installed splines2 which was available and I assume is similar enough thet I can make it work. However I don't know what to do with graphins. I can't find anything similar at CRAN, CRAN2, R-Forge, or rforge.net. Is there another repository that I should be using?
Thanks!
- AnonymousNot applicable
hello!
is there a newer version of this? the script to install dependencies is no longer working.
- andymc123Advocate III
I have R installed, but I am a rookie. I was able to install all of the necessary packages so that the sample .pbix file provided here loads and works just fine for me. When I try to add the spline visual to my own .pbix file it doesn't want to accept measures in the X and Y axis. Message on the visual simply states "Need numeric X and Y variables". They are numeric, the Data Type is "Decimal Number", but formatted as "Percentage". Why wouldn't I be able to use measures? The data I have works just fine with the built in Power BI "scatter chart". What I really want is the line so that I can keep a National Average line on the visual and cross-highlight by districts to see the distance from a National Average.
Very cool visual, I hope that I can get it working.