Forum Discussion

RichardT_78's avatar
RichardT_78
Helper I
3 years ago
Solved

Time stamps

I am trying to look at a specific event in order to use the date and time stamp to use the datediff function but i cant filter or issolate the timestap that i need to make the function work correctly...
  • v-yueyunzh-msft's avatar
    3 years ago

    Hi , RichardT_78 

    According to your description, you want to get the datediff between the latest timestamp each Car and the Now().

    If this , you can refer to these steps .

    (1)My test data is the same as yours.

    (2)We can create a measure:

    Measure = var _cur_car_table = FILTER(ALLSELECTED('Table') ,'Table'[Car ]= MAX('Table'[Car ])&& 'Table'[fault ]=1678)
    var _t2= ADDCOLUMNS(_cur_car_table,"minus" , ABS([Time stamp ]-NOW()))
    var _latest =  MINX(_t2,[minus])
    var _t3 = FILTER(_t2 ,[minus] = _latest)
    return
    DATEDIFF(MAXX(_t3,[Time stamp ]),NOW(),HOUR)

    (3)Then we can meet your need:

     

     

     

    If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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