Login / Register  search  syndication  about

          George Jensen's Blog

George Jensen on Reporting, Business Intelligence, Crystal Reports, Visual Analyzer, and more.

Using Crystal Reports "Next" and "Previous" Functions

Today  I am going to write about  the "Next" and  "Previous" Functions available with Crystal Reports.  As their names describe the intent of these functions is to provide you a value of your selected field for either  the Next or the Previous record as shown in your report.

For example if I wanted to determine the number of days it has been since a History record has been written against an Account in SalesLogix,  I could use these two functions along with the DateDiff function  to organize our data.  Let me give you an idea of how!

First, create a SalesLogix report with the History table.  Make sure to create two groups, group 1 is for the Account Name - sorted ascending, group 2 is by History Complete Date - sorted ascending by second.  The group level fields are used in the report.  Use your Section Expert to have group1 overlay group2.  Set the fields in the two groups so they would line up into columns if they were next to each other.  Also,  I  suggest suppressing all group footers and the detail section in your report.

Now create a formula field called "Next" and add the following formula:

IF {HISTORY.ACCOUNTNAME} = Next ({HISTORY.ACCOUNTNAME}) then CSTR(Next ({HISTORY.COMPLETEDDATE})) else ""

This formula states if the current records Account Name does not equal the next records Account name then do not show the next records Complete date.   If you do not include the account comparison in the formula then "Next" will display a value for the next record even if it is not from the same account. 

Add this field anywhere in History Group 2.  If you put this field by the complete date you will see that the field displays the date of the next records complete date.  The last record under the group for the Account will be blank.  What I want is this last History record that was added for this Account and none of the others so I will use this blank field to my advantage.  My group 2 suppression formula looks something like this.

{@Next}<>""

This should bring you down to just one record per account.  Since none of the data showing has a "Next" value so remove that field from the report.

Let's go ahead and create another field called "Previous" using the following formula:

IF {HISTORY.ACCOUNTNAME} = Previous ({HISTORY.ACCOUNTNAME}) then CSTR(CDATE(Previous ({HISTORY.COMPLETEDDATE}))) else ""

This field is very similar to the "Next".  Add this field to the report and you will see that you now have the date of the previous History record.  If the value is blank then there is not a previous record in the system

So you now know the Complete date of  the last History record along with the Complete Date of  record prior to the last History record, but how long has it been since the last History record?  Create one final formula field called "Days Since" using this formula:

DateDiff ("d",{HISTORY.COMPLETEDDATE},CurrentDate)

Add this to your group 2 and you will have all the information you need to see what Accounts are in need of some attention.

 

Thanks

Geo

 

 

 

What's This?
  
Bookmark and Share

About George Jensen

   George Jensen is a Senior Developer for Customer FX Corporation.


Related Content
   Mobile 3.0.3 for Saleslogix v7.5.4, v8.0.0 & v8.1.0 is now available!
Saleslogix Mobile v3.0.3 is now available in the customer portals. This update addresses all issues int
Posted on Apr 14, 2014 by Scott Weber to SalesLogix Product Blog
 
   Editing Filters in Saleslogix Web Client 8.0
Is it possible to add or remove Saleslogix filters from the List view in Accounts?
Posted on Apr 08, 2014 by SalesLogix Support to SalesLogix Questions & Answers
 
   Creating a Unique Saleslogix table ID in a SQL Function
A couple of months ago Ryan Farley wrote an article about how to use a SQL stored procedure to create a S
Posted on Mar 25, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Saleslogix Integration with Google - WOW!
Saleslogix will be releasing their Google Integration this month and from what I have seen, it is fantast
Posted on Mar 18, 2014 by Scott Weber to SalesLogix Product Blog
 
   Global Joins in the Saleslogix Web Client
Question: How can I make a Global Join stick in the Saleslogix Web Client? Currently, when I create a
Posted on Mar 07, 2014 by SalesLogix Support to SalesLogix Questions & Answers
 
Comments

 

Twitter Trackbacks for Using Crystal Reports "Next" and "Previous" Functions - George Jensen's Blog [customerfx.com] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Using Crystal Reports &quot;Next&quot; and &quot;Previous&quot; Functions - George Jensen's Blog         [customerfx.com]        on Topsy.com

January 22, 2010 4:54 PM
 

Chaitra said:

Hi,

I am working on crystal report conversion to SSRS.I wanted to know how to convert this NEXT formula from crystal report to SSRS

April 14, 2010 2:10 AM
 

Sojan said:

How to get the previous and next of a calculated value

December 9, 2010 7:21 AM
 

Sojan said:

I want to get the pervious of a summary value (which is created from a TransValue field in stored procedure)

December 9, 2010 7:23 AM
 

eddie villano said:

hi guys, i just want to share this one.

If you are looking for better reporting software, please take a look at Windward Reports. With Windward you design reports in Microsoft Word, Excel, or PowerPoint so report design is a lot faster and easier - and non-programmers can design reports.

reporting software

www.windwardreports.com

April 21, 2011 11:16 PM
 

Kunal said:

Hi is there ssrs equivalent to next() method of crystal report please reply

July 21, 2011 8:06 AM
 

Dee said:

Can this work at a Group level,

i.e to get a total of the Previous Group?

May 11, 2012 3:23 AM
 

pookeye said:

I would also like to know if this works on a group level,  I tried doing next(GroupName)   it doesnt work...    i was reading up online and it mentioned something about changing the next function to include groups, but i was unable to find out how to go about doing this.

September 4, 2013 3:43 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2014 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register