Forum Discussion

elif's avatar
elif
Frequent Visitor
4 years ago

If statement doesn't work

Hello,

I have a problem with IF statement which is not working perfectly, do you have any idea why it is not working very well?

 

is grater = VAR maxtable1 = CALCULATE(MAX('Date'[Date]),USERELATIONSHIP('Product'[NPI End Date],'Date'[Date])) VAR maxtable2 = CALCULATE(MAX('Product'[NPI End Date])) RETURN IF ( maxtable2 >= maxtable1, 1, 0)
 
POS Type NEW = IF([is grater] = 1, "NPI", 'Product'[POS type])
 

 

 There is an inactive relationship between the Product'[NPI End Date] and Date'[Date]

5 Replies

  • elif , If this is a column, this will not work

    POS Type NEW = IF([is grater] = 1, "NPI", 'Product'[POS type])

     

    It needs to be a measure

    example

    POS Type NEW = IF([is grater] = 1, "NPI", max('Product'[POS type]) )

    • elif's avatar
      elif
      Frequent Visitor

      Hi amitchandak 

       

      I tried both of them but still not working. When I try your suggestion it gives me just 2 Product Type but has to be 5 like Core Product, Identity, NPI, Custom, outofscope, and the NPI calculation is wrong as well.

       

       

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, elif ;

    Can you share  a simple data removing sensitive information, along with the results you want to output?

    It makes it easier to give you a solution.

     

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, elif ;

    Is your problem solved? If so, Would you mind accept the helpful replies as solutions? Then we could close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.