Blogs / SAP / SAP Analytics Cloud / R Visualizations / SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets

Dec 20, 2019

SHARE

In the previous blog in this series, we learned how to swap, sort and rank R widgets. In this blog, we will see how to leverage slider widgets in SAP Analytics Cloud analytic applications to interact with R visualization.

***

The scenario is to analyse the customers that have the highest debt ratio (here the debt is considered doubtful when the overdue amount is > 120 days). A slider is used to control the minimum doubtful debt, and Range Slider is used to control the percentage of doubtful debt within the total amount due.

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
Slider and Range Slider in action

You can see how the Slider and Range Slider widgets are used as a measure filter for R Visualization in action below.

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
Slider and Range Slider in action

Add Slider and Range Slider

Add a slider to the canvas and configure it with minimum, maximum and default values as shown below.

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
Slider configuration in SAP Analytics Cloud

Add a range slider and configure it. You can modify the look and feel in the Styling panel.

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
Range Slider configuration in SAP Analytics Cloud

Passing input variables to R

Add the following scripts in the OnChange event of Slider and Range Slider widgets to pass the values to R Visualization.

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
Slider OnChange event script

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
Range Slider OnChange event script

The getValue() function is used to get the values from the slider. Similarly, getStartValue() and getEndValue() does the same job for range slider component. Debt_value, Precent_debt_min and Precent_debt_max are R input variables, and these are set using the setNumber() API.

Add the following script in the OnInitialization event to initialize the variables to R Widget and avoid errors on application startup.

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
Application OnInitialization script

Initializing the Data Frame in R Widget

Add R Visualization widget to the canvas and choose a data source. After which you will be able to add rows and columns from the Input Data panel. You can find a detailed explanation on creating and adding data frames here. Select the fields required, in this case, Company, Customer dimensions and Doubtful Debt, % Doubtful Debt measures.

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
R Data Frame initialized with rows and columns

R Data Frame initialized with rows and columns

plotly  – Scatter Plot Visualization

This blog uses the plotly library to produce enhanced visuals. You can refer to the blog Adding Interactivity and Customizations to  R widgets for more detailed customizing options in plotly.

The R script in the snapshot below explains how to create a scatter plot chart and modify the axis limits based on the user selection made from Slider widgets.

SAP Analytics Cloud – R Visualization Series 5 – Leveraging Measure Filters using Slider Widgets
R script to plot a scatter chart in SAP Analytics Cloud

Save and run the application. When you make a selection in the sliders, the corresponding values get passed to R Visualization and the R script gets executed visualizing a scatter plot. You can try adding the functionality to multiple charts and filter types as well.

***

Check out our other blogs on the R Visualization series here. Reach out to us here today if you are interested in evaluating if SAP Analytics Cloud is right for you.


Corporate HQ:
5920 Windhaven Pkwy, Plano, TX 75093

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192

solutions@visualbi.com


Copyright © Visual BI Solutions Inc.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Share This!

Share this with your friends and colleagues!