Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Is there a way to allow .10 difference when comparing decimal numbers for equality

Is there any function in DAX that will allow a .10 difference for decimal numbers when comparing for equality?

For example, I have 2 calculated measures (decimal numbers) and I would like to return the below results:

 

M1 = 136.50

M2 = 136.40

result= IF (M1=M2, yes, no)

 

Output: Yes for the above values.

 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Nevermind, I got the solution

    Status=
    var subr = ABS(M1-M2)
    var result = IF(AND(subr >= 0.01 , subr <= 0.10) || M1= M2 ,"Yes", "No")
    return result

     

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      I would like it to be dynamic since this will return "no" when numbers are the same and should return yes in that case.

      for example, when both the measures are 136.50 then it should return yes as well. I would want it to return yes when:

      They match

      Also when there is a difference .10 (max) else return no

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Anonymous 

    Try

    result= IF (M1=M2+0.10 || M1=M2-0.10, yes, no)

  • Anonymous's avatar
    Anonymous
    Not applicable

    Nevermind, I got the solution

    Status=
    var subr = ABS(M1-M2)
    var result = IF(AND(subr >= 0.01 , subr <= 0.10) || M1= M2 ,"Yes", "No")
    return result

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous 

      Can you post the solution here.