Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Difference between rows based on ascending time

Hi guys I want to calculate differences between volume per ID. I have no possibility to create Index in PQ.

So for example I want the yearliest value that day for that ID to be 0, then as per example :

7.17-7.16

7.16-7.15 and so on

 

2 Replies

  • Anonymous , Try

    A new colum =

    var _max = maxx(filter(Table, [Id] = earlier([ID]), [Timestamp at Datetime] <earlier([Timestamp at Datetime] )),[Timestamp at Datetime] )
    return
    if(isblank(_max), blank(), datediff(_max,[Timestamp at Datetime] , second))

     

    or a new measure


    measure =

    var _max = maxx(filter(allselected(Table), [Id] = max([ID]), [Timestamp at Datetime] <max([Timestamp at Datetime] )),[Timestamp at Datetime] )
    return
    if(isblank(_max), blank(), datediff(_max,max([Timestamp at Datetime]) , second))

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you, amitchandak but getting errors:

       

      also tried rermoving last part "