Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9091

Re: Record count since last occurrence - Crystal 2013

$
0
0

First your image above shows descending dates rather than ascending. So chronologically John Smith only had 1 loss prior to his first win not 3. Here is how I would do it assuming I understand your goal correctly.....

 

Create a formula to place in the group header. I called it reset

numbervar loss_cnt := 0;

numbervar array last_ten := [0,0,0,0,0,0,0,0,0,0];

stringvar Last_ten_output := "";

booleanvar win := false;

WhilePrintingRecords;

 

Create a second formula and place it in the details section. I called this one Calc.

numbervar loss_cnt;

numbervar array last_ten;

stringvar Last_ten_output;

booleanvar win;

local numbervar i;

WhilePrintingRecords;

if {WinField} = 1 then win := true ;

if win = false  and {WinField} = 0 then loss_cnt := loss_cnt + 1 ;

for i := 1 to 9 do

(

last_ten[i] := last_ten[i+1];

);

last_ten[10] := {WinField};

if sum(last_ten) = 0 then Last_ten_output := "10" else Last_ten_output := "";

sum(last_ten)

 

Create the next two formulas and place them in group footer. I called them loss_b4_win and Last_Ten

//loss_b4_win

numbervar loss_cnt;

WhilePrintingRecords;

loss_cnt

 

//Last_Ten

stringvar Last_ten_output;

WhilePrintingRecords;

Last_ten_output

 

If it all works correctly you can go back and right click the formula in detail section - format field common and check suppress so that it doesnt show up in the report.


Viewing all articles
Browse latest Browse all 9091

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>