Forum Discussion

abodqmm's avatar
abodqmm
Regular Visitor
2 years ago
Solved

Datediff negative results

guys i have a start time end an end 

i calculate it right but there some wrong entries like the end time before the start and the results show in negative 

in the datedif i want to make he negative result as blank how can i do it 

 

= DATEDIFF('TableName'[start_time],'TableName'[end_time],MINUTE)
 
i want to make it count only the correct time results with negative i want them to appear as blank ??????????
  • Hi abodqmm 

    You can modify your formula to below:

    =
    VAR __DIFF =
        DATEDIFF ( 'TableName'[start_time], 'TableName'[end_time], MINUTE )
    RETURN
        IF ( __DIFF < 0, BLANK (), __DIFF )
    

     

    My question  now is why would the difference return negative values? Shouldn't the end always be later than the start? You might need to include in your calculation the dates as well.

  • Hello abodqmm ,

     

    try the following

    Column = 
    var diff = DATEDIFF('TableName'[start_time],'TableName'[end_time],MINUTE)
    RETURN
    IF(diff < 0,BLANK(),diff)

     

2 Replies

  • Hi abodqmm 

    You can modify your formula to below:

    =
    VAR __DIFF =
        DATEDIFF ( 'TableName'[start_time], 'TableName'[end_time], MINUTE )
    RETURN
        IF ( __DIFF < 0, BLANK (), __DIFF )
    

     

    My question  now is why would the difference return negative values? Shouldn't the end always be later than the start? You might need to include in your calculation the dates as well.

  • Hello abodqmm ,

     

    try the following

    Column = 
    var diff = DATEDIFF('TableName'[start_time],'TableName'[end_time],MINUTE)
    RETURN
    IF(diff < 0,BLANK(),diff)