Rounding when Exporting to Excel

When you use the rounding feature in Crystal Reports you generally do so, as follows:
(Right Click on the Field > Format Field > Number > Customize)
rounding

You can select the number of decimal places to which you wish to Display in the Report.

However, When you export this to excel you will still get the full Value.

For example. If the Value was 56.76999999
And you have select to round to 2 Decimal places.
The Report will display 56.77

However when you export, the field will be 56.76999999

If you would rather have the export to excel match the report.

Simply add a formula which performs the rounding.

Round({Table1.Fieldname1},2)

This will mean when you export. The Excel Field will match the Value Displayed in the Report.

 

Categories: Uncategorized

BI4 OpenDocument Null Parameter

With the release of BI4 there have been a few changes to the structure of OpenDoc URLs in business Objects 4.0. 

Crucially a lot of people would need to pass Null Value into a report for a required parameter. This used to be just a case of entering no value or the text Null, but that no longer seems to work in BI4. 

To get around this, you can now pass the ASCII Value %00 instead of Null.

For Example 

&lsSProductName=%00

Perhaps this will change in the future, but for now this has worked. 

Categories: Uncategorized

Display Plus(+) and Negative (-) signs before a number

If  you wish to display a plus sign in front of a numeric value for a report. perhaps to ease the reading of positive and negative values, or show an increase in an amount or value, often the negative sign will be display automatically.

You will however need to display a plus(+) sign to positive values. Or nothing at all for a zero (0) amount.

The following code will append a Plus sign to the front of positive numbers and leave a Zero as it is.

If {table.value} > 0 then

‘+’ + totext({table.value}, 0, “”)

Else if {table.value} = 0 then
totext(table.value}, 0, “”)
else

totext({table.value, 0, “”)

Categories: Crystal Reports

Last Day of Previous Year or First Day of Current Year Calculation in Crystal Reports

January 10, 2012 2 comments

You have a requirement to use the last day of the previous year or the first day of the current year and you don’t want to be hard coding any values into the report.

Very simply.

For Last Day of Previous Year: Create a Formula @PrioYearEnd

date(Year(currentdate)-1,12,31)

 

For First Day of Current Year simply remove the -1 from current date;

date(Year(currentdate),01,01)

 

 

Subtract Month Crystal Report

If you have a date field and wish to derive the previous month from that date, use the formula below.

DateAdd ("m", -1, CurrentDate)

This Is particularly useful for Prior Month Calculation.

 

Obviously you can adjust the -1 value to calculate any number of months previous. i.e to identify 12 Months Prior from a particular date you would use the formula

DateAdd ("m", -12, CurrentDate)

CurrentDate can also be replaced by whichever date field you require.

Categories: Crystal Reports

Crystal Reports – No Records Error / Splash Screen

September 16, 2011 Leave a comment

There isn’t much more confusing for an end user than facing a blank screen, with no idea if the screen has loaded, caused an error, or frozen.

When writing crystal reports its important to understand that returning no records is a possibility in a lot of cases and this must be effectively communicated with the user on-screen.

No Records Splash Scren Crystal Reports

No Records Splash Scren Crystal Reports

By default, crystal will not display a no records splash screen or display any error messages. It will simply display your Report Header and page headers and the details will be left blank. This could possibly cause issues for the users as they will no be sure as to whether no records have been returned on if there was some sort of error.

In order to create a crystal Report No Records Splash screen, we need to create a report header which will display a message, should no records be returned by the query.

If you have an existing report header such as our fictional “No. Of Products Per Site Report” –  you simply create a second report header.

Right Click on Report Header in design view and select “insert section below”.

This will create a section called “report header b”. This will contain the message you wish the user to see should no records be returned.

We now want to suppress this section of report so that it only displays when we have no records.

Right Click on our “Report Header b” and select “selection expert”. On the common tab, select the formula editor for Suppress (No Drilldown).

In the formula put the following formula

count({Table1.Field1}) <> 0

Ensure that the suppress checkbox is not checked. See image below.
The red Mark on the forumla box shows that a forumla is enetered in the supression criteria.

Suppress Report Header

This formula will mean that the header will not be displayed if the count of your record field does not equal 0 records.

Page Header.

You will also probably want to hide your column headings if there are no records.

To do this, again go to the “selection expert” and tick the “Suppress (No Drill-Down) checkbox and then click on the formula button and enter.

            if isnull({Table1.Field1}) then true

Page Header Suppression

Page Header Suppression

Thats It!

Now when no records are returned you should be able to see the splash screen telling the user that no records are available.

Crystal Reports cell alignment and export issues

Are you experiencing issues with your crystal reports exporting?

Can’t get the cells to align correctly when exporting to excel?

We have explained a few simple things you can do to resolve these. Just view our article on Crystal Reports Cell alignment

Don’t have the time and want a helping hand? You can email us. We will do it for you.

We will get your crystal report looking exactly as you wish, and exporting to excel in perfect alignment. For only $50/£30/E30 per report.

Email us now if you want more information.

Categories: Crystal Reports

Remove trailing character in Crystal Reports Formula

This is a relatively straight forward formula to help you remove the last character of a string.

It may be that you wish to remove a period from the end of a field name or an inverted comma. Here we will call our field {DBField1}

 

left({DBField1},len({DBField1})-1)

All we are doing here is using the left function to display all the characters to the left, excluding the last chacter, (which is determineted by the “Len” function)

NOT IN Syntax – Excluding records in Crystal

So you need to exclude a few records from your reports in Crystal.
Perhaps that stray erroneous record in the DB which has never been fixed, or a list or exclude customers for a certain country/state.

If you have a list of values and you want to exclude them, then NOT IN will help you do to this. This can be used for both record selection, or on the suppression criteria for groupings.

So lets say you want to exclude customer ID’s 1512, 1563 and 1765 from appearing in your report.

Simply add in your selection criteria;

NOT({CustomerID} IN [“1512″,”1563″,”1765”])

Crystal Reports combine a separate Date and time field into 1 field

If you have a situation where you have your date and time stored in 2 separate DB fields. You may wish to combine these, either for display, formatting or sort purposes.

To do so, you simply use the following code.

Where Field1, is your date field and Field2 is your Time Field

 

datetime(Field1,Field2)

 

Categories: Crystal Reports