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
   Video: Demystifying Infor CRM (Saleslogix) Updates
Watch it now! If you missed yesterdays demo, "Demystifying Infor CRM (Saleslogix) Updates" ,
Posted on Sep 26, 2014 by Brianna Ojard to The Inbox
 
   Thoughts on the Future and Involvement in the Saleslogix/Infor CRM Community
Over the last year and a half I've been working on another product named Contatta. It's a great p
Posted on Sep 25, 2014 by Ryan Farley to Ryan Farley's Blog
 
   Fixing the Orphaning of Salesfusion Data when Converting Leads to Contacts in Infor CRM (Saleslogix)
We have had a couple of client recently come to other with the same problem-When you convert a Lead to a
Posted on Sep 19, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Official Infor CRM Acquisition FAQ
What to expect now that Saleslogix is Infor CRM. Like many of you, it will take some time (probably a
Posted on Sep 18, 2014 by Brianna Ojard to The Inbox
 
   ComboFix Kills Saleslogix Sync
ComboFix, a third party malware utility, will alter the Operating system so .qts and .que files will no l
Posted on Sep 12, 2014 by Brianna Ojard to SalesLogix Support
 
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
 

Rob said:

I have been beating my head for a week trying to solve a problem my regional managers approached me with and these simple expressions solved it for me. THANK YOU!!

June 11, 2014 10:31 AM

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