Conditional expression

Conditional expressions are not allowed in Stimulsoft reports by default. However, there are two ways to force conditional behavior as needed.

IIF function

First, a built-in that can be inserted from the data dictionaryIIFYou can use the function. This function uses the following syntax:

{IIF (condition, value 1, value 2}

It evaluates the Condition, and if Condition returns true, the expression returns Value1. If false is returned, Value2 is returned. For example, if you enter the following formula:

Number of stores: {Store.Count> 0? Store.Count: “None”}

If the Store.Count value is 10 after the calculation, the result displayed in the report will be:

Number of stores: 10

If the value of Store.Count is 0 after the calculation, the result displayed in the report is as follows.

Number of stores: None

C # ternary operator

It is also possible to use the ternary operator with C # as the reporting language if you are using it. The syntax for the ternary operator is:

{situation ? Value 1: Value 2}

As with the IIF function, if Condition evaluates to true, the expression returns Value1. If false, returns Value2.