This is a migrated thread and some comments may be shown as answers.

IF Function question

4 Answers 36 Views
ExpressionEditor
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 06 Nov 2012, 03:02 AM
The IF function does not appear to support fields as the ifTrue or ifFalse parameters.
For example using constants like this works -
    IF(Discontinued,0,1)
but using a field like this doesn't -
    IF(Discontinued,0,UnitPrice)

Why is this? The IF function is quite limited if we can only use constants.
Can you explain or offer a solution?

Thanks
Brian

4 Answers, 1 is accepted

Sort by
0
Jarred Froman
Top achievements
Rank 1
answered on 16 Nov 2012, 02:59 PM
We are experiencing similar situations ourselves.  For example, if we are evaluating nullable doubles, the following fails to evaluate:
IF(MyValue1 = null, 0, MyValue1)

whereas, this does evaluate:
IF(MyValue1 = null, 0.0, MyValue1 + 0.0)

Thanks,
Jarred
0
Dimitrina
Telerik team
answered on 19 Nov 2012, 01:58 PM
Hi Jarred,

The reason why the first expression does not work should be that the types that you return in the [ifTrue] and [ifFalse] are different. Please note that there is no implicit conversion between the two values. 

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jarred Froman
Top achievements
Rank 1
answered on 19 Nov 2012, 07:41 PM
MyValue1 is a nullable double so the following doesn't work either:
IF(MyValue1 = null, 0.0, MyValue1)

Expecting users to enter values in their strictest type is not intuitive.  Is there a way of making this more forgiving for numerical values?
0
Dimitrina
Telerik team
answered on 21 Nov 2012, 05:44 PM
Hello,

 I am afraid that this would not be possible. You cannot control or cast the values additionally.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ExpressionEditor
Asked by
Brian
Top achievements
Rank 1
Answers by
Jarred Froman
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or