Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Sum where a field value is not null Post Reply Post New Topic
Author Message
Jukka Heikkinen
Newbie
Newbie


Joined: 23 Sep 2010
Online Status: Offline
Posts: 2
Quote Jukka Heikkinen Replybullet Topic: Sum where a field value is not null
     Posted: 23 Sep 2010 at 9:48pm
Hi all.

This must look real lame but I just cannot figure out the Crystal Reports syntax. No problem at all doing this in standard SQL, but CR really baffles me.

Here's the deal

We have a shipping document, where I need to add a sum of the weights of certain hazardous goods.

The MS SQL-server does have these fields

document.NETWEIGHT,document.HAZARDCODE

I just want to have a sum of the document.NETWEIGHT where the document.HAZARDCODE is not null / empty. Or sum where there's something in the .HAZARDCODE will do just as well.

I've tried this, I've tried a lot of other things, but no joy.
Sum ({document.NETWEIGHT},{document.HAZARDCODE}, not "")

So how do I get CR to sum only those weights, and leave the non-hazardous weights out?

Cheers, Jukka



IP IP Logged
saoco77
Senior Member
Senior Member


Joined: 26 Jun 2007
Online Status: Offline
Posts: 104
Quote saoco77 Replybullet Posted: 24 Sep 2010 at 3:41am
There are likely numerous solutions. One example:

Formula - 1

if isnull({document.HAZARDCODE},) then 0 else {document.NETWEIGHT}

Formula 2

sum(@formula1)
IP IP Logged
Jukka Heikkinen
Newbie
Newbie


Joined: 23 Sep 2010
Online Status: Offline
Posts: 2
Quote Jukka Heikkinen Replybullet Posted: 26 Sep 2010 at 7:47pm
Thanks, got it working now. Sure saved me a lot of headache. I could have had it made by our CRM-provider, but working with their support is such a pain that I avoid it as far as I possibly can.

Jukka
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum