IF Condition in SAP analytics cloud

Overview: In this tutorial you will learn and understand IF condition in SAP analytics cloud and how to use it

IF Condition

IF condition is the logical function used in SAP analytics cloud, it returns the value based on TRUE condition, In this IF condition we don’t have ELSE condition so if statement is FALSE it will return NULL values. so after condition we pass only one argument in this IF condition.

In IF and ELSE condition we have two arguments to pass one for TRUE value and another for FLASE value.

IF (Condition True, Return value)

Note: Return value of IF condition always have numeric values, text cant be return

Lets understand it with examples:

Example #1: IF condition on Numeric value

Lets we are applying IF condition for numeric value to check if value is greater then or less then and based on that IF condition return the values

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

In above example we have compare Revenue is greater then 5000 then it will show revenue in new column else it will show NULL values as shown below image

table view to show the calculation of IF condition on Numeric value

On above example IF condition checked the value for Revenue which is greater then 5000 and shows revenue values, if it is less then then it will show NULL values.

Example #2: IF condition on String or Dimension

Lets take example to apply condition on string or on dimension columns and return value will be Numeric

In below example we have applied condition on Region = “West”, if it is TRUE then it will show the revenue esle NULL values

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

Output of above example will be look like this as shown below image

Here you can se West region have NULL values as it is not satisfied with IF condition.

table view to show the calculation for if condition on string

Example #3: IF condition for Mathematical Calculation

In this example you will see how you can use calculation in IF condition, you can use basic mathematical operators to calculate on measures easily.

In below example we are trying to double the revenue if revenue is more then 10,000.

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

table view to show the calculation for if condition on mathematical calculation

Example #4: IF condition using String Function

In this example, you will see how you can use String Function in IF condition. You can apply any string function to check some condition and accordingly you will get the result. you can use IF condition formula for both table and chart view (like combined chart, Time series chart etc..)

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

In above formula we are tying to double the revenue for those product which start with “B” alphabet

and result will look like as below

table view to show the calculation for IF condition using string function

Scroll to Top