Forum Discussion

ArchStanton's avatar
ArchStanton
Power Participant
2 years ago
Solved

OR Operator affecting my IF Statement

Does anyone know why and how to stop this code giving me a TRUE/FALSE in my calculated column?

 

Validation to Closure = IF(ISBLANK('Cases'[applicationvalidationdate]),BLANK() || IF(ISBLANK('Cases'[Resolution Date]),BLANK(),
                        DATEDIFF('Cases'[applicationvalidationdate],'Cases'[Resolution Date],DAY))+1)

 

It is something to do with the || (OR) operator because without the || there is no TRUE/FALSE only a DATEDIFF Count.

 

IF(ISBLANK('Cases'[applicationvalidationdate]),BLANK(),
                        DATEDIFF('Cases'[applicationvalidationdate],'Cases'[Resolution Date],DAY))+1

 

Thanks

  • Yes. If you have A || B, then the expected result is true/false.

     

    Did you mean to write your measure like this:

    Validation to Closure =
    IF (
        ISBLANK ( 'Cases'[applicationvalidationdate] ) || ISBLANK ( 'Cases'[Resolution Date] ),
        BLANK (),
        DATEDIFF ( 'Cases'[applicationvalidationdate], 'Cases'[Resolution Date], DAY ) + 1
    )
    
  • Hi,

     

    The OR statement shouldn'e be an issue, might be the way it's worded with 2 If statements instead of just 1 with an OR.  Try this:

     

    Validation to Closure = if('Cases'[applicationvalidationdate] = BLANK()||'Cases'[Resolution Date]= blank(), BLANK(), DATEDIFF('Cases'[applicationvalidationdate],'Cases'[Resolution Date],DAY)+1)
     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

4 Replies

  • Yes. If you have A || B, then the expected result is true/false.

     

    Did you mean to write your measure like this:

    Validation to Closure =
    IF (
        ISBLANK ( 'Cases'[applicationvalidationdate] ) || ISBLANK ( 'Cases'[Resolution Date] ),
        BLANK (),
        DATEDIFF ( 'Cases'[applicationvalidationdate], 'Cases'[Resolution Date], DAY ) + 1
    )
    
    • ArchStanton's avatar
      ArchStanton
      Power Participant

      This is perfect - many thanks!

  • DOLEARY85's avatar
    DOLEARY85
    Resident Rockstar

    Hi,

     

    The OR statement shouldn'e be an issue, might be the way it's worded with 2 If statements instead of just 1 with an OR.  Try this:

     

    Validation to Closure = if('Cases'[applicationvalidationdate] = BLANK()||'Cases'[Resolution Date]= blank(), BLANK(), DATEDIFF('Cases'[applicationvalidationdate],'Cases'[Resolution Date],DAY)+1)
     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍