Forum Discussion

rebrow31's avatar
rebrow31
Helper I
4 years ago
Solved

Find the difference between earliest and latest datetime

Hi,    I have a table which holds data for every part that is produced. When a part is produced, it has a date time stamp (see below):     I have then easily created a visual which shows m...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi rebrow31 ,

     

    I think you can try DATEDIFF function in your code.

    Calculated column:

    Column = 
    VAR _SECOND = DATEDIFF('Table'[Earliest DateTime],'Table'[Latest DateTime],SECOND)
    RETURN
    DIVIDE(_SECOND,60)

    Measure:

    Measure = 
    VAR _Summarize = SUMMARIZE('Table','Table'[Earliest DateTime],'Table'[Latest DateTime],"Minute", DIVIDE(DATEDIFF('Table'[Earliest DateTime],'Table'[Latest DateTime],SECOND),60))
    RETURN
    SUMX(_Summarize,[Minute])

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.