Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to handling Nulls in subtotaling

Status
Not open for further replies.

sk8er1

Programmer
Jan 2, 2005
229
US
I need to build in subtotals. The value I am counting is a date field. If there is a date, I want to add to a formula field, if it is NULL, I want to add to another formula field. I must set the report options to convert NULLS to their default values right????
Now, for the formula field, would this work..
If {Date} = Date(0,0,0) then 1
or
If IsNull({Date}) then 1

Then put those formula fields in the group footer>>>>>
 
Do a pair of running totals. Have them count some other field, such as a name or account number. But make the running totals conditional - one on the date being null and the other not.

Note that 'Isnull' tests must always be done first, because Crystal formulas stop when they encounter a null for anything except an 'Isnull' test.

The coverse of Isnull is not IsNull

Right-click on a field and choose Insert to get a choice of Running Total, Summary and Grand Total. Or else use the Field Explorer, the icon that is a grid-like box.

It is also possible to get get totals using a Formula Field, which can contain a Variable or a Directly Calculated Total.

Running totals allow you to do clever things with grouping and formulas. They also accumulate for each line, hence the name. The disadvantage is that they are working out at the same time as the Crystal report formats the line. You cannot test for their values until after the details have been printed. You can show them in the group footer but not the group header, where they will be zero if you are resetting them for each group.

Summary totals are cruder, but are based directly on the data. This means that they can be shown in the header. They can also be used to sort groups, or to suppress them. Suppress a group if it has less than three members, say.

Grand totals are much like summary totals, but for the whole report rather than groups. Note that summary totals include an option to have a grand total calculated on the same basis.


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Do not check "convert null to default value". Try the following for your formula:

if isnull({table.date}) or
{table.date} = date(0,0,0) then 1

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top