Troubles with IsNull Crystal Reports - crystal-reports

I'm using Crystal Reports 12.3 and Peachtree Accounting 2012 to manage some database. My task now is simply make a report that contains customers that have not placed orders in last 30 days. I'm new to it so I'm asking your help.
My first trying was to use this formula (I'm doing all my stuff in Formula Editor -> Record Selection):
not ({Customers.LastInvoiceDate} in Aged0To30Days)
Everything seems to be fine except null values. I need to include in report records with null values. So I rewrite the formula to:
not ({Customers.LastInvoiceDate} in Aged0To30Days) OR IsNull({Customers.LastInvoiceDate})
But in Peachtree Accounting 2012 I'm seeing a customer with a blank LastInvoiceDate field which is not in report.
Is there some kind of bug in my last formula? Or is there some "other" black values for DateTime type?

You should always check for nulls first, so try reversing the second formula to
isnull({Customers.LastInvoiceDate}) or not({Customers.LastInvoiceDate} in Aged0To30Days)
If Crystal encounters a null and it is not explicitly handled first, then the rest of the formula will crap out and not evaluate. Another way to get around this is to tell Crystal to use 'Default Values for Nulls' instead of 'Exceptions for Nulls' in the Formula Workshop (It's a dropdown setting in the Formula Workshop toolbar).

length(trim({Customers.LastInvoiceDate})) = 0
One statement with no need for isnull function and OR operator.

Related

Crystal Reports Record Section not returning same data as sql

I found a solution that another Tech had posted:
New Formula:
{Product.Size} <> “xsm” or IsNull({Product.Size})
Unfortunately, when preview your report, you will find that this doesn’t work. That is not because of a mistake in our logic but rather, what I consider to be a bug in Crystal Reports. If I took this exact same condition and applied it to the database records using a query analyzer or querying tool, I would see the blank records. Unfortunately, Crystal is not allowing the null values to come through even though our formula says that they should.
The trick to circumventing this bug is to put the IsNull() check FIRST in the formula.
Thus, if we rearrange the condition to this:
IsNull({Product.Size}) or {Product.Size} <> "xsm"
WORKED LIKE A CHARM
Problem is, if I select criteria for the second OR statement ({HiredRate.UTRANSDOC}startswith{?TransYN}) and NO for the first ({HiredRate.UTRANSWEB}startswith{?WebYN}) I get only one record that meets the TransYN criteria. If I switch places in the formula putting ({HiredRate.UTRANSDOC}startswith{?TransYN}) 1st I get all of the data.
When I run the SQL query I get all of the data no matter what order they are in. The Crystal Preview only gives me all of the data on the first from the OR section.
The only thing that stands out looking at the data from SQL is that the one record Crystal is returning has YES in the Transdoc field and the Transweb field is blank. All other records show YES for Transdoc and NULL for the Transweb field.
Here is the Crystal Record Selection Formula
{HiredRate.CONTSUPREF} startswith {?LanguageCombo}
and {HiredRate.ONDATE} = {?ProjectDate}
and {HiredRate.ACTVCODE}= "SIG"
and {HiredRate.RESULTCODE} = "CLM"
and (
{HiredRate.UTRANSWEB}startswith{?WebYN}
or {HiredRate.UTRANSDOC}startswith{?TransYN}
or {HiredRate.UTRANLANL0}startswith{?LanloYN}
or {HiredRate.UINTCONSEC}startswith{?InterpYN}
or {HiredRate.UINTCONF}startswith{?IntConfYN}
or {HiredRate.UINTOPI}startswith{?OPIYN}
)
Here is the SQL query Crystal is using:
SELECT HiredRate.DEAR, HiredRate.CONTSUPREF, HiredRate.LASTDATE, HiredRate.CONTACT, HiredRate.USOURCLANG, HiredRate.UTARGLANG, HiredRate.UTRANSDOC, HiredRate.UTRANSWEB, HiredRate.UTRANLANL0, HiredRate.UINTCONSEC, HiredRate.UINTCONF, HiredRate.UINTOPI, HiredRate.ONDATE, HiredRate.ACTVCODE, HiredRate.RESULTCODE
FROM GoldMine_Main.dbo.HiredRate HiredRate
WHERE HiredRate.CONTSUPREF LIKE 'ENG>SPA%' AND (HiredRate.ONDATE>={ts '2012-04-01 00:00:00'} AND HiredRate.ONDATE<{ts '2013-04-06 00:00:00'}) AND HiredRate.ACTVCODE='SIG' AND HiredRate.RESULTCODE='CLM' AND (HiredRate.UTRANSWEB LIKE 'NO%' OR HiredRate.UTRANSDOC LIKE 'YES%' OR HiredRate.UTRANLANL0 LIKE 'NO%' OR HiredRate.UINTCONSEC LIKE 'NO%' OR HiredRate.UINTCONF LIKE 'NO%' OR HiredRate.UINTOPI LIKE 'NO%')
ORDER BY HiredRate.DEAR, HiredRate.CONTACT
This is happening because the {HiredRate.UTRANSWEB} is null - the rest of the expression is therefore evaluating as null in Crystal, even though (logically) it shouldn't.
When the first two or conditions are swapped around, the {HiredRate.UTRANSDOC} condition evaluates as true and the rest of the expression is short-circuited - which is why records are then selected.

Crystal Reports suppress 0 in Pie Chart

Thanks in advance for any help,
I have a Crystal Report made in Crystal Reports 2011. The report does a simple select from a view and uses about 6 of the columns.
In 2 consecutive sections there is a Cross Tab and a Pie chart, both reporting on the same formula field. The formula for the field is as follows:
iif( IsNull({IROView.OVERTURNREASON})=false, {OVERTURNREASON},"")
Basically, if my value is not null, I get the value, and if it is, I get an empty string.
In the Cross Tab, under the Customize Style tab, there is a Suppress Empty Rows and Suppress Empty Columns check box. I am looking for something similar for the pie chart because even though there is no slice for the empty string, the legend has a an entry for the blank string with the value 0 (or 0%).
Thanks again,
You may want to consider updating the charting engine to use the latest version of CRChart. Three-D Graphics wrote the original component for SAP (nee BusinessObjects nee Crystal Decisions nee Seagate Software); they own the source code. The #HIDE_ZERO macro would probably do exactly what you need to have done.

Crystal Report - Placing decimal point

I'm getting an integer value as 2345 but I want to display it as 234.5
is it possible??
To get what you are looking for in a simple fix is like what kingpin stated above. Divide the value by ten. To do this just create a new formula in crystal by going into your field explorer and right clicking on the formula fields section. Under there should be a option to create a new formula. Then in window that comes up put the field you want to manipulate in the formula and then divide that by ten. And there you go. Now use the formula field in the report instead of the original field.
Here is a example of how it could look.
{Table_Foo.value_Bar} / 10
There is a field property for it. Don't have access to crystal reports at the moment, but I know it's there:
Crystal Report Provides an easy to use default thousand separator for numeric Fields. You can use it by checking Thousand Separator from Field Properties.
If you need a customized separator, check Customized Thousand Separator in Crystal Report.
You also might want to find some tutorials on the Crystal Reports themselves if you still have trouble.

Inserting Missing Dates into Crystal Report

I'm using Crystal Reports 10.
In my database I have production values for each Date. There's a date column and a qty column. When I run a report on this the dates on the report correspond to the dates in the database, but I'd like the report to display every date and if there is no value for it a 0. Is this possible to do right in the report?
The date is a group field with detail suppressed. The numeric values are a sum of the details placed in the group header, if that makes a difference.
You have 2 questions.
To display a 0 for null values, you can go into your options menu and "convert database NULL values to default"
Alternatively, you can use make a new formula with this code and use if isnull({Table1.Amount}) then 0 else {Table1.Amount}. I recommend this option since it won't affect other fields in the report.
To display every date, you should make a 'helper/index' table in your datasource and right-join your actual data to it. Crystal can't display data for, say, 01/07/2010 if there are no records for it.

crystal report problem

what is the equivalant command like in vb for EOF(), MoveNext, Moveprevious commands in crystal reports
There are no equivalent answers in Crystal Reports, at least not in the versions I have used. Crystal Reports more or less simply dumps the data out into the report.
That said, if you are in a detail row, and you want to find out what the next value of a field will be, you can use:
next({YourColumn})
You can also find out the previous column value by using this:
previous({YourColumn})
Keep in mind that Next() won't work on the last record, and Previous() won't work on the first record.
I'll have to double-check, but I believe there is an OnLastRecord function that returns TRUE if you are on the last record.
First, welcome to SO!
Second, you sound new to Crystal Report's purpose is to display data, not perform the kind of calculations you're talking about. CR usually goes record-by-record through the data, displaying (or suppressing) each record, and adding group headers & footers.
To answer your question, LittleBobbyTables does give a few good pointers. To see the entire list of functions available to you, there is a list in the Formula Editor (see pic below). Press F1 for detailed descriptions of each command.
You can also:
Create a "Running Total Formula" that will evaluate each record and give a calculation in the group footer.
Do the calculations outside of Crystal Reports and only feed the end result in (perhaps with an unlinked join to your primary table).
The most complex option is to make a subreport that does the calculation and feeds the result back to the main report
Can you give us some more details about what you're trying to do?