Forum Discussion

KristofferAJ's avatar
KristofferAJ
Icon for Helper III rankHelper III
4 years ago
Solved

If Statement in powerquery

Hi 
I need to tweek my datediff calculation to blank out when the results are negative, but I cant't seem to get it right

[START DATE]
[END DATE]

= IF ([END DATE - [START DATE]) >0
then
([END DATE - [START DATE])
Else
null
???


  • Hello KristofferAJ ,


    Please try creating custom column as -

     

    if Duration.Days([EndDate]-[StartDate]) < 0 then null else Duration.Days([EndDate]-[StartDate])

     

     

     

     

    Please mark it answer if it solves your issue. Kudos are also appreciated.

     

     

2 Replies

  • Hello KristofferAJ ,


    Please try creating custom column as -

     

    if Duration.Days([EndDate]-[StartDate]) < 0 then null else Duration.Days([EndDate]-[StartDate])

     

     

     

     

    Please mark it answer if it solves your issue. Kudos are also appreciated.

     

     

  • KristofferAJ 

    Zero here is a duration, so try the following 

    = if  [End Data]-[Start Date] > #duration(0,0,0,0) then  [End Data]-[Start Date] else null