SimonFreeman
SimonFreeman

Reputation: 205

Crystal Report - gather previous value on specific context

I have an output on Crystal from a query, recordset is:

DATE        TIME        FLOC    VALUE
01/07/2015              AAA 
02/07/2015  01:30:00    AAA     00MC
02/07/2015  03:30:00    AAA     00SE
03/07/2015              AAA 
04/07/2015              AAA 
05/07/2015              AAA 
06/07/2015              AAA 
07/07/2015              AAA 
08/07/2015  08:00:00    AAA     00MP
08/07/2015  14:00:00    AAA     00SE
01/07/2015              BBB 
02/07/2015  09:30:00    BBB     00MP
02/07/2015  16:30:00    BBB     00SE
03/07/2015              BBB 
04/07/2015              BBB 
05/07/2015              BBB 
06/07/2015              BBB 

I would like to create an additional column with a previous value depending on context valuation:

FOR same DATE and FLOC 
IF TIME <= "04:00:00" THEN CHECK = VALUE
ELSE CHECK = DATE-1 VALUE

Obtaining something like this:

DATE        TIME        FLOC    CHECK   VALUE
01/07/2015              AAA     
02/07/2015  01:30:00    AAA     00MC    00MC
02/07/2015  03:30:00    AAA     00SE    00SE
03/07/2015              AAA     00SE
04/07/2015              AAA     00SE
05/07/2015              AAA     00SE
06/07/2015              AAA     00SE
07/07/2015              AAA     00SE
08/07/2015  08:00:00    AAA     00SE    00MP
08/07/2015  14:00:00    AAA     00SE    00XX
01/07/2015              BBB     
02/07/2015  09:30:00    BBB             00MP
02/07/2015  16:30:00    BBB             00XX
03/07/2015              BBB     00MP
04/07/2015              BBB     00MP
05/07/2015              BBB     00MP
06/07/2015              BBB     00MP
07/07/2015              BBB     00MP
08/07/2015              BBB     00MP
01/07/2015              CCC     
02/07/2015  22:30:00    CCC             00MC
02/07/2015  23:30:01    CCC             00MC
03/07/2015              CCC     00MC
04/07/2015              CCC     00MC
05/07/2015  23:00:00    CCC     00MC    00YY
06/07/2015  01:00:00    CCC     00SE    00SE
07/07/2015              CCC     00SE
08/07/2015              CCC     00SE

Any idea on how to handle this on Crystal? Thanks a lot. Kind Regs S.

Upvotes: 0

Views: 32

Answers (1)

SimonFreeman
SimonFreeman

Reputation: 205

I've used Previous() function + EvaluateAfter() for the context env. Thx.

Upvotes: 1

Related Questions