Print Page | Close Window

Increment number based on criteria

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=11921
Printed Date: 06 May 2024 at 1:15pm


Topic: Increment number based on criteria
Posted By: leighturner
Subject: Increment number based on criteria
Date Posted: 21 Dec 2010 at 4:49am
Based on a previous formula @NewPallet, every time this occurs I would like to add 1 onto a count value.
 
For example:
 
Head1    NewPallet    Count
1                                    1
2                                    1
3                                    1
4              NewPal          2
5                                    2
6              NewPal          3
 



Replies:
Posted By: lockwelle
Date Posted: 21 Dec 2010 at 5:29am
shared numbervar iCount;
if @newPallet then
  iCount := Count + 1;
 
iCount
 
this assumes that @newPallet returns true of false, adjust the if statement as needed.
 
HTH


Posted By: leighturner
Date Posted: 21 Dec 2010 at 5:36am
Thank you for the response.
 
My formula is:
 
@iCount
shared numbervar iCount;
if mailto:%7b@NewPallet - {@NewPallet } = "Start of new pallet"
then  iCount = iCount + 1;
 
@iCountTot
shared numbervar iCount;
iCount
I am getting zero for every record?


Posted By: lockwelle
Date Posted: 22 Dec 2010 at 3:26am
it looks ok, did you place the iCount formula on the report...I have forgotten to do that ;)  I am also assuming that mailto:%7b@newPallet - {@newPallet } returns that exact verbiage, otherwise it will never increment.
 
you also could move the increment logic to the mailto:%7b@newPallet - {@newPallet } formula, and when it determines it is a new pallet to increment the shared variable
 
HTH



Print Page | Close Window