Search code examples
reporting-servicesreportingservices-2005

How to subtract the value of a row from the previous value using a Reporting Services Expression?


Using the following SQL Query:

SELECT     
   TOP (100) PERCENT 
   ID_BADGE, 
   LEFT(RIGHT('000000' + CAST(TIME_TRX AS varchar), 6), 2) 
     + ':' + SUBSTRING(LEFT(RIGHT('000000' + CAST(TIME_TRX AS varchar), 6), 4), 3, 2) AS ClockTime, 
   DATE_TRX, SEQ_REC, ROWID
FROM
   omi.TAHIST_ZERO
WHERE     
   (ID_BADGE = '     ' + @Badge) 
   AND (DATE_TRX BETWEEN @Date AND @Date2) 
   AND (SEQ_REC IN ('0', '1000')) 
   AND (CODE_TRX IN ('100', '101'))
ORDER BY 
   DATE_TRX, TIME_TRX

I have created the following table:

screenshot of ssrs table

Using a Reporting Services Expression I want to subtract the second value of ClockTime from the third value of ClockTime.

I looked through the VB Functions and all I could find were First, Last, Min, and Max, not second or third.


Solution

  • I think you could achieve this using the SSRS Previous function:

    http://msdn.microsoft.com/en-us/library/ms156372(v=sql.90).aspx