Post

1 follower Follow
0
Avatar

Use case function for number comparison

Hi,

 

|

 

|

Rita Hienekamp

Sep 15 15:21

Hi,

Can anyone tell me how to compare 2 numbers using a case function? If the value is < 75, then I want to show "On Track", if the value is between 75-90, I want to show "At Risk" and if the value is above 90, I want to show "Off Track".

When I try to use the case statement, I am not able to get the right results comparing numbers. The examples and the documentation only show string comparisons.

I need to do something like: 

{Case(round((($ActualEffort/ Hours(1) * 100)/$Work)),

'"<'+'75','LOWER','HIGHER')}

Whatever I try, it always shows me HIGHER. Note that I have 3 possibilities, so an IF statement won't work... unless I can use nested IF statements.

|

Rita Hienekamp Answered

Please sign in to leave a comment.

3 comments

0
Avatar

Hi Rita,

 

Thanks for reaching out!

With a Case function you can't define numeric ranges, however you can use nested IF statements like you stated.

The syntax should like this:

If(Condition1, Result1, If (Condition2, Result2, Result3))

Please feel free to join one of our Advanced Q&A webinars for more help with customizations.

 

Warm Regards,

Tamir

Tamir Avital 0 votes
Comment actions Permalink
0
Avatar

Hi Rita,

Just in case (pun intended) you are like many people who find the case statement easier to read than nested if statements, you can combine the two.

{Case(If(INPUT<75,1,If(INPUT<100,2,3)),1,"ONE",2,"TWO",3,"THREE","OTHER")}

This can be visually easier to read as it puts the computation right up front - your criteria numbers of 75 and 100 comprise the expression, then the case statement completes the thought.

Honestly I rarely do it this way, but it is an option.

Good luck,

CE

CE Raum 0 votes
Comment actions Permalink
0
Avatar

Thank you both! I'm using the nested IF and it works well :)

Rita Hienekamp 0 votes
Comment actions Permalink