Skip to Content
Technical Articles

How to visualise processes in SAP Analytics Cloud using a funnel chart

Recently one of our customers asked me how a funnel chart can be integrated into a SAP Analytics Cloud story. Especially in sales reporting like lead-to-order, funnels are very good way to visualize the process from first customer contact to the sales order. This also applies to any other process visualization one might require.

At this moment SAP Analytics Cloud does not offer a funnel chart as part of its standard visualizations. Therefore, I wanted to show how to create a funnel chart using R visualizations in  stories. The possibility to use R visualizations in stories has been available for quite some time now (see also https://www.sapanalytics.cloud/resources-using-r-visualizations/).

Personally I found the plotly library the easiest way to build a funnel, there is nice introduction to funnels available https://plotly.com/r/funnel-charts/, which was my main source of information.

Background

The objective is to visualize data as a simple funnel with the possibility to match the colors to the theme of the story. The business case is to visualize the expected revenue as per current sales status. The data is taken from data model “SAP_Cloud4Customer”, which is provided in every SAP Analytics Cloud Tenant as part of the example data set “Management Dashboard”. You can activate this example data in your tenant via the Content Network.

The model contains the measure “number opportunities” and a status assignment in the dimension “Sales Phase”:

Dataset

Implementation

Create a new story, add the model “SAP_Cloud4Customer” to the story and create a new R visualization.
Then assign the necessary input data (“Sales Phase” and “Number Opportunities” from account filtered to Actual):

Data%20Selection

Now you are ready to enter the script and we will start off with a basic funnel by using the following code:

library(plotly)

# build funnel:

fig <- plot_ly()

fig <- fig %>%

add_trace(

type = "funnel",

y = SAP_Cloud4Customer$`Sales Phase`,

x = SAP_Cloud4Customer$`Number Opportunities` )

# plot the funnel

fig

This already provides a result:

First_result

However an alphabetic order of the phases is not what is required. Instead we need the semantic order of “Identify opportunity”, “Qualify opportunity”, “Develop value proposition”, “Quotation” and “Close”. So we need to arrange our data into the specific order.
This is done by applying a factor to the dimension “Sales Phase” and thus giving it the required order. The factor is defined by listing the values of “Sales Phase” in the required order:

SAP_Cloud4Customer$`Sales Phase` <- factor(SAP_Cloud4Customer$`Sales Phase`, levels = c("Identify opportunity", "Qualify opportunity", "Develop value proposition", "Quotation", "Close"))

Then rearrange the data using this factor:

SAP_Cloud4Customer <- SAP_Cloud4Customer %>% arrange(SAP_Cloud4Customer$`Sales Phase`)

This must be done before building the funnel and then we get the right order of data in the funnel:

This is nice and exactly what we need from a data point of view – except that the blue color scheme might not fit the colors used in the story.  It is not possible to reuse the color settings from the story, so colors have to be assigned manually in R. This is done by adding a marker to the funnel plot. Colors can be defined by name or Hex code. To apply the exact same colors to the funnel as in my story, I simply took the Hex codes from the continuous sequential color palette that I used in the story:

marker = list(color = c("#0d6499", "#405c8e", "#7b5382", " #c04974", " #f24269") )

Adding the marker to our funnel now provides a funnel that fits nicely into the overall story:

The final R script is as follows:

library(plotly)

# brig data into requred format:
SAP_Cloud4Customer$`Sales Phase` <- factor(SAP_Cloud4Customer$`Sales Phase`, levels = c("Identify opportunity", "Qualify opportunity", "Develop value proposition", "Quotation", "Close"))
SAP_Cloud4Customer <- SAP_Cloud4Customer %>% arrange(factor(SAP_Cloud4Customer$`Sales Phase`, levels = c("Identify opportunity", "Qualify opportunity", "Develop value proposition", "Quotation", "Close")))

# build funnel:
fig <- plot_ly() 
fig <- fig %>%
  add_trace(
  type = "funnel",
    textinfo = "value",  
  y = SAP_Cloud4Customer$`Sales Phase`, #dimension
  x = SAP_Cloud4Customer$`Number Opportunities`, #measures
  marker = list(color = c("#0d6499", "#405c8e", "#7b5382", " #c04974", " #f24269") ) ) 

# plot the funnel
fig

Conclusion

It is possible to build a funnel chart in SAP Analytics Cloud using R visualizations. And the funnel chart provides a great way to visualize the current state of a process. It’s easy to start and get result and there are a lot more ways to layout the chart (please refer to the plotly funnel reference (https://plotly.com/r/reference/#funnel). So go ahead and try it!

1 Comment
You must be Logged on to comment or reply to a post.