IF Function question

5 posts, 0 answers
  1. Brian
    Brian avatar
    4 posts
    Member since:
    Feb 2012

    Posted 05 Nov 2012 Link to this post

    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

  2. Jarred Froman
    Jarred Froman avatar
    57 posts
    Member since:
    Aug 2008

    Posted 16 Nov 2012 Link to this post

    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
  3. DevCraft banner
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Nov 2012 Link to this post

    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.

  5. Jarred Froman
    Jarred Froman avatar
    57 posts
    Member since:
    Aug 2008

    Posted 19 Nov 2012 Link to this post

    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?
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 21 Nov 2012 Link to this post

    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.

Back to Top
DevCraft banner