Skip to Content
Technical Articles
Author's profile photo Geetha Madhuri Bobbili

Dynamic R Visualization in SAP Analytics Cloud

Author: Geetha Madhuri Bobbili
LinkedIn Profile: https://www.linkedin.com/in/geetha-madhuri-bobbili-971268184/

Introduction:

In this blog, we will create an Analytic application to switch between two different R visualizations. For R Visualization basics in SAP Analytics Cloud, please refer to this blog.

Step 1: Create the R Visualization in Analytic application.

i. Name the R visualization as RVIZ_1. Within the Builder panel of the RVIZ_1 widget, choose the Add Input Data button.

ii. Here I have selected the model: BestRunJuice_SampleModel as input data for my R visualization.

iii. Choose the Add Dimensions button and select the required dimensions. I have selected Date, Sales Manager, Location and Product in the Rows. Gross Margin, Original Sales Price and Quantity Sold in Columns.

iv. Within the Builder panel, click on the entry BestRunJuice_SampleModel and rename it to Model.

v. Within the Builder panel, choose the Add Script button. Type the following code into the Editor section.

vi. The R script will create an animated scatter chart displaying the measures Quantity sold on the x-axis and Gross Margin on the y-axis. The data points for each Sales Manager should be visualized in a different color.

vii. Define an if/else logic within the R script to either visualize Scatter chart or Bar chart.

Step 2: Create an Input Control to filter the Charts by Sales Manager.

Step 3: Create two buttons to switch between different R Visualization Styles.

Create the buttons BUTTON_SCATTER_CHART and BUTTON_BAR_CHART and define the following script logic.

Click on the Buttons within the Outline area and choose the Edit Script button and select the onClick option to start the script editor.

Step 4: Save and run the Analytic Application .

Select one of the sales managers in the Input Control, choose the buttons and check if the chart changes.

Conclusion:

Now we have created Dynamic R Visualizations in SAP Analytics Cloud.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Manish Gupta
      Manish Gupta

      Good one