IF and Else condition

Overview: In this tutorial you will learn IF and ELSE condition in SAP analytics cloud and how you can use this condition in your SAC stories and chart.

IF and ELSE condition

ID and Else condition in SAC is the logical condition and it is use to return a value based on TRUE and FALSE condition. IF first condition is TRUE then it will return first argument values, if first condition is FALSE then it will return ELSE argument value. we don’t use ELSE keyword here in SAP analytics cloud the second argument is default ELSE value.

You can use IF condition formula for both table and chart view (like combined chart, Time series chart etc..)

Note: IF and ELSE condition always return numeric values

Lets understand with syntax:

IF (Condition True, Return value1, Return value2)

// value2 is return when the condition is FALSE

Lets understand it with examples:

Example #1: IF and ELSE condition on Numeric value

In this example we are applying IF and ELSE condition for numeric value based on mathematical operators like =, >, < to check if value is greater then or less then and based on that IF and ELSE condition return the values

IF( [“SalesData”:Revenue] > 5000 , [“SalesData”:Revenue], [“SalesData”:Revenue] * 2)

In above example we have compare revenue is greater then 5000 then it will show only Revenue, ELSE it will show double Revenue in new column (double revenue is just multiply by 2)

You can see output as shown below image, the red marked cell result double Revenue because of condition is TRUE.

Example #2: IF and ELSE condition on Dimension or Text

Lets take example to apply IF and ELSE condition dimension columns (for condition on text) and return value will be Numeric

In below example we tried to apply IF condition on Region = “East”, if it is TRUE then it will show the double revenue else it will show on current Revenue

IF( [d/”SalesData”:Region] = ”West” , [“SalesData”:Revenue] * 2, [“SalesData”:Revenue] )

below image shows the how output will look like, the red marked result double Revenue because of condition is TRUE.

Example #3: IF and ELSE condition using String Function

You can also use String Function in IF and ELSE condition in SAP Analytics cloud. You can apply any string function to check condition and based on condition you will get the result.

IF( LEFT ([d/”SalesData”:Product].[p/ID], 1) = ”C”, [“SalesData”:Revenue] * 2, [“SalesData”:Revenue] )

In above formula Revenue will be double if product start with “C” alphabet, ELSE it will return current Revenue

Below is the output image, the red marked cell shows the double Revenue as String function condition satisfied

Scroll to Top