Print Page | Close Window

Build and Display Unique Values

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20468
Printed Date: 29 Apr 2024 at 5:59am


Topic: Build and Display Unique Values
Posted By: vcs1161
Subject: Build and Display Unique Values
Date Posted: 13 Feb 2014 at 5:08am

I need to build multiple dates in one field that is grouped by a customerID.  This process is working with the exception of it repeating the same date more than once.  There can be multiple items for the customer on the same date but I just want the UNIQUE date to be displayed once and not for each record line.  Can someone guide me as to where I am going wrong and if there is a solution for this?  Greatly appreciated.

For instance I get 12/23/2013, 12/23/2013, 12/28/2013 if the customer had more than one item on the same day.  I would like this to display as 12/23/2013, 12/28/2013.

 
This what I am using to build the date s in the field:
whileprintingrecords;
stringvar CertainDates;
if CertainDates<> ""
then CertainDates:= CertainDates+ ", ";

CertainDates:= if {Command.FieldName} = 1 then CertainDates+ ToText (({Command.Date}),"M/dd/yyyy " );

Then I am displaying them in the CustomerID group footer:
whileprintingrecords;
stringvar CertainDates;
CertainDates;
 
This is reset on the CustomerID group header:
whileprintingrecords;
stringvar CertainDates;
CertainDates:= " ";



Replies:
Posted By: kevlray
Date Posted: 13 Feb 2014 at 5:27am
if the dates are in order then it should be fairly simple.  If not, then it becomes much more difficult.  The easiest is probably checking the current row with the previous row;  Something like this;

If previous({Command.Date}) <> {Command.Date} then do the code to add the date toe CertainDates

I hope this helps.


Posted By: vcs1161
Date Posted: 13 Feb 2014 at 5:53am
Thank you very much.  I was not familiar with the Previous function.  I believe it is now working the way I need it to.  I found that I need to do the opposite with
If previous({Command.Date}) = {Command.Date}. Smile
 
I did look this up in the Crystal Help tool now that I am aware of it and this is how it is explained:
 
Tests the previous value in the {file.QTY} field to see if it is a zero value. If it is not, it divides the value by two. If it is a zero value, it returns the value itself.
If Previous ({customer.CUSTOMER ID}) = {customer.CUSTOMER ID} Then
     "Repeated Value"
Else
     ""
I sincerely appreciate your prompt attention and guidance to get me through this.
 



Print Page | Close Window