How to Make a What-If Analysis Using Input Widget in CRM Analytics

Ramdosk
4 min readAug 19, 2022

I really excited to see the Winter 23 releases feature of the “Input widget”.Yay!!!!!!!!!!!!!! now we can easily perform the What-If Analysis in CRM Analytics.

Let’s dive in!

What is Input Widget:-

The Input widget captures numeric values and uses them as a data source for use in other dashboard widgets and formula queries.

For example, use values from the input widget to perform what-if calculations, such as

a.)The effect of inventory shortages on profit margins

b.)What would be my sales commission if I increase my Sales Value

c.)what would happen if we improved our sales from 0–100%

I believe Input Widget is one of the most powerful tools for exploring your data and providing interactivity to your end users. The best way to think of Input Widget is that they act as wildcards. In the simple algebraic equation 4X = 24, the value of X would be the Numeric value of the input widget; in this case, equal to 6. The reason Input Widget is so powerful is that you or your end users can change the value of X from 6 to any number, which will change the results of a view.

Use cases — what would happen if we improved our sales from 0–100%

we will use this concept to create a What-If analysis that will show us what would happen if we improved our sales from 0–100%. For this Demonstration, we are using the Kaggle Sample Sales dataset.

1. Let’s start by creating a simple line graph showing sales over time:

Sales over Time

2. Set up your Input widget

Drag and drop an Input widget to your dashboard grid (1)

Slider Input Type
Freeform Input Type

In the widget properties, click Input Type (2) to specify how to capture data. such as a slider or Freeform Input.

Select a display format (3), such as currency or percentage.

Add minimum (4)and maximum values (5) and change increments (7) as the input range. so that the end user can select any number between zero and 100 with respective increments selected.

Add a start value (6) which will be the default value for Input Widget. Let's say it would be the Initial selection.

Note:-

if you select Input Type as “Freeform Type” then Increments configuration is not applicable.

Input Values Configuration

There are some additional options available under “Input Style” including the “Show values range”, and “Show current value” (which is applicable only for Slider Input Type)

Input Style Configuration

This Input Widget is a dependent variable, meaning that it does not do anything on its own. To use it in our view, we will create a calculated field that leverages this Input Widget to calculate the value dynamically.

Since we are creating a what-if analysis that shows how our sales would change if they improved by 0–100 percent. There are a couple of ways to write this calculation; here is one:

[Target Field] * ( 1+Input widget output/100)

Notice that Input Widget output can be used in a Calculation by leveraging the Bindings.

(‘Target Field’)*(1+{{cell(input_1.selection, 0, \”input\”).asObject()}}/100)

Now we have our Line chart and Input Widget lets do the final magic to make it interactive. To create two lines on the same axis, one for actual sales and one for “what_if_sales”, make the “Sales Over Time” query as a SAQL step where we will create a New calculated field for “what-if sales”. we are using the same formula as mentioned above. below is the final SAQL Query

“q = load \”sales_data_sample\”;\n

q = group q by (‘ORDERDATE_Year’, ‘ORDERDATE_Month’);\n

q = foreach q generate ‘ORDERDATE_Year’ + \”~~~\” + ‘ORDERDATE_Month’ as ‘ORDERDATE_Year~~~ORDERDATE_Month’, sum(‘SALES’) as ‘sum_SALES’,sum(‘SALES’)*(1+{{cell(input_1.selection, 0, \”input\”).asObject()}}/100) as ‘what if sales’;

q = order q by ‘ORDERDATE_Year~~~ORDERDATE_Month’ asc;

q = limit q 2001;

Now we have a way to control the input for the What If Sales Calculated Field.

this is just one example of an Input Widget that can be used for. it has more power to build high-level Analytics.

Happy learning!!!!!!

--

--