Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
su1
Contributor II
Contributor II

If statement with variable ignoring equal sign

Hello everyone, 

I have a variable (vGoal) and it has 80 as both the definition and the value. 

I have a master measure called MM.

I am using this If statement:

If (MM <= vGoal, 'Good', 'Bad')

The problem is that when MM is 80, it should be 'Good', but it is showing me 'Bad'.

I think the problem lies with the equal sign. It won't work when I do this: 

If (MM = vGoal, 'Equal')

It only works when I do this: 

If ( MM < 80.5 AND MM > 79.5, 'Equal')

I can't think of anything I might be doing wrong. Thank you for your help.

Labels (1)
1 Solution

Accepted Solutions
su1
Contributor II
Contributor II
Author

It doesn't work. There is no output after I used your If statement. 

I ended up using this If statement: 

If ( MM < (vGoal+0.5) AND MM > (vGoal-0.5), 'Good', 

    If (MM > vGoal, 'Bad', 'Good')).

 

View solution in original post

4 Replies
Chanty4u
MVP
MVP

Just try this 

If (Num(MM) = Num(vGoal), 'Good', 'Bad')

 

marcus_sommer

I think MM hasn't really the value of 80 even if it looked like that else it's probably something like 80.00000000001.

This means some kind of rounding will be needed or maybe another kind of the query, for example something like:

pick(sign(MM - vGoal) + 2, 'Good', 'Good', 'Bad')

su1
Contributor II
Contributor II
Author

It doesn't work. There is no output after I used your If statement. 

I ended up using this If statement: 

If ( MM < (vGoal+0.5) AND MM > (vGoal-0.5), 'Good', 

    If (MM > vGoal, 'Bad', 'Good')).

 

su1
Contributor II
Contributor II
Author

Your formula is still giving me Bad at 80. I ended up using this If statement:

If ( MM < (vGoal+0.5) AND MM > (vGoal-0.5), 'Good', 

    If (MM > vGoal, 'Bad', 'Good')).