Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Cannot Convert value of type text to type true false

Hello
 
I am having this error for "Decreased" choice in this formula below. it is urgent for me. 
Can you please help  me ? 
 
Measure =
if([Rate of Imp. Ord]<0,"Decreased "
|| [Rate of Imp. Ord]>0 ,"INCREASED")
 
Thanks in advance
  • Hi, Anonymous 

     

    you do not need to use or operator here. Simple use increased in the else statement of the if func. like this, 

    Measure =
    IF([Rate of Imp. Ord] < 0, "Decreased", "INCREASED")

     

2 Replies

  • rubayatyasmin's avatar
    rubayatyasmin
    Icon for Community Champion rankCommunity Champion

    Hi, Anonymous 

     

    you do not need to use or operator here. Simple use increased in the else statement of the if func. like this, 

    Measure =
    IF([Rate of Imp. Ord] < 0, "Decreased", "INCREASED")

     

  • edhans's avatar
    edhans
    Icon for Community Champion rankCommunity Champion

    You cannot put two condtions in an IF like that with different results. rubayatyasmin is partially correct, but that solution doesn't handle if your [Rate of Imp. Ord] is zero. It woud show Increased with that logic. 

    You could do this two ways. Nested IF:

    aMeasure =
    IF(
        [Rate of Imp. Ord] < 0,
        "Decreased ",
        IF(
            [Rate of Imp. Ord] > 0,
            "INCREASED"
        )
    )
    

    Better way IMHO because it is more readable and easier to expand if you have more than 2 conditions. 

    aMeasure =
    SWITCH(
        TRUE(),
        [Rate of Imp. Ord] < 0, "Decreased ",
        [Rate of Imp. Ord] > 0, "INCREASED"
    )