The Result Data Newsletter   
Volume 709 - September 2007   
© Copyright 2007 Result Data Consulting, Ltd.  614-505-0770  www.resultdata.com   

    Result Data Home Page  |  Newsletter Archive  |  Upcoming Events  |  Classes & Workshops  |  Request Information
Upcoming Events:  Mid Ohio BusinessObjects User Group: 11/14, Data to Dashboards:  11/14

Return to Newsletter Contents...

 

Custom Functions

by: Kristen St. Jean, Sr. Consultant, CRCP

Crystal reports in a very powerful reporting tool that allows us to connect to many types of databases and semantic layers including Business Objects Business Views and Universes. 

However, sometimes just pulling data into our reports from the data source isn’t enough.  We need to manipulate the data to display in a way so that it’s useful for end users of the report.  We may need to create calculations to determine a profit for instance.  This would include using fields such as tax, gross sales, cost of goods sold, and anything else that our business determines should to be taken into consideration when calculating profit.  Once we have a definition, we can then create a formula in Crystal Reports that calculates our profit and display it as a field on the report so that the end users do not need to manually perform this calculation. 

Crystal Reports has a very robust formula syntax which allows us to manipulate data in many ways to ensure that we can give our end users exactly what they want to see on a report.  The only drawback to creating formulas is that sometimes they can become very complex and when a certain complex formula is requested on multiple reports, it can become cumbersome to recreate this formula multiple times.  For example, our profit calculation from above needs to add and subtract multiple fields and it needs to be created on many reports because most of our users want to see profit on their reports. 

If we recreate the formula on each report, the report creation process will be extended because we are repeating steps that we’ve previously taken, and we run the risk of accidentally calculating profit incorrectly.  In order to make a report creation more efficient and reduce the risk of errors, Crystal Reports has the ability to create Custom Functions. 

A Custom Function is a function that is defined by the report designer.  For example, if our Profit calculation is Gross Sales – Cost of Goods Sold – Tax Paid we could create a function by opening the Formula Editor and choosing New – Custom Function.  We could name the Function ‘Net Profit’, and choose ‘Use Extractor.’  This will allow us to point to an already created formula and extract the logic used.  In this case, we would choose our Profit formula, and the Extractor would extract our logic and everywhere that we had used a field in the formula that will become a variable.  Our Function, ‘Net Profit’, will have three variables.  These will be labeled v1, v2, and v3, but we can edit those names to be more descriptive such as, Gross Sales, Cost of Goods Sold, and Tax Paid.  Now, we know that when we use this function, these are the three items that need to be included for the function to work properly.

Up to this point, ‘Net Profit’ is a Report Custom Function and can only be used in the report we are currently working on.  In order to share it with other reports we can add it to the Repository if our company has Business Objects Enterprise.  The Repository will allow us to store our Custom Function and use it in other reports.  By right-clicking on our Custom Function ‘Net Profit’ in the Formula Tree in the Formula Editor, we can choose ‘Add to Repository’ from the speed menu and save our Report Custom Function into the Repository making it a Repository Custom Function and anyone who has access to the Repository will be able to use the Custom Function that we have created.

In this way, Repository Custom Function can greatly reduce the time it takes to create reports that share the same complex formula logic and help to reduce errors in the creation of formulas that need to be standardized across reports.

Go to Top  |  Return to Newsletter Contents

The Result Data Newsletter is published approximately once a month to share the latest information on business intelligence, data management and CRM. There should be a link below to allow you to change or remove yourself from our list. We take your requests very seriously. If you have any difficulty please contact us at 614-505-0770 and we will make sure that your request is handled properly. This is not intended to be an unsolicited message and you can reach us in person if needed.

© Copyright 2007 Result Data Consulting, Ltd. - All Rights Reserved
All trademarks and copyrights are the property of their respective owners. This information is provided without warranty.
Announcements
Fall Training Special
Get a jump on your Christmas shopping!  Schedule and attend any public training class now through December and receive a FREE $50 gift card to Target, Barnes & Nobles or Best Buy (restrictions apply).  Call 614-505-0770 for further details and restrictions.
BI Designed and Priced for Mid-Sized Companies
Join us on Sept. 26 for a special presentation just for mid-sized businesses and find out how companies like your are improving their performance using business intelligence (BI).  Call 614-505-0770 or click here to reserve your seat.
Next MOBOUG Meeting
The next Mid-Ohio Business Objects User Group (MOBOUG) meeting is November 14, 2007.  Call 614-505-0770 or click here to reserve your seat.
Data to Dashboards
Join us on November 14th to learn about the methods and tools that can transform your data into highly functional and robust dashboards, reports and analytics.  Data-to-Dashboards will provide an overview as well as live demonstrations of the complete process that collects, transforms and delivers your data using industry leading Business Intelligence software.  Enjoy a comprehensive review of the concepts and tools that deliver top quality BI content to your user community.  Call 614-505-0770 or click here to reserve your seat.
Looking for a Few Good Men and Women
Join our award winning team of Business Intelligence consultants and .Net Software developers.
Send your resume and salary requirements to:
jobs@resultdata.com