Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Insert Null or Do Not Count Null Post Reply Post New Topic
Author Message
tdavenport
Groupie
Groupie
Avatar

Joined: 21 Oct 2008
Location: United States
Online Status: Offline
Posts: 41
Quote tdavenport Replybullet Topic: Insert Null or Do Not Count Null
     Posted: 29 Feb 2012 at 5:28am
I have an If - Then - Else formula that I am using to evaluate occurrences of internet browsers. I have one for each browser (IE, Chrome, etc...).

For 'true' the formula inserts a unique id. I have nothing for 'false'. When I summarize with a distinct count my result is X + 1. X for each correct unique id and the extra count is the one blank value that is being counted. I'm using distinct count-In actuality, there are hundreds of blank values for when a browser version does not exist.

So if there were 1900 installations of Firefox, my final count would be 1901 - using distinct count.

Is there a way to write my formula that will prevent the blank value from being counted in my summarization? Is there a way to change my summary so that it does not count the blank value?

I thought that I might be able to INSERT a null value when my formula returned false but I can't seem to get the syntax right (if one exists). I'm also not sure that it would still not be counted as a blank.

Any ideas are welcome.

Thank you!
Any and all suggestions are welcome.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Feb 2012 at 5:40am

You can use RTs or variable formuals

or
there is no syntax for returning a NULL but there is a trick
create a formula field called NULL
do not put anything in it and save it.
now you can use it in your if them formula as
if whatever as your true then table.uniqueid else {@NULL}
IP IP Logged
tdavenport
Groupie
Groupie
Avatar

Joined: 21 Oct 2008
Location: United States
Online Status: Offline
Posts: 41
Quote tdavenport Replybullet Posted: 29 Feb 2012 at 5:55am
Nmind...
I think I figured it out. I just embedded my original if then else formula into a new formula that subtracted 1.

DistinctCount ({@IS Explorer}, {@Region}) - 1

It works!
Any and all suggestions are welcome.
IP IP Logged
tdavenport
Groupie
Groupie
Avatar

Joined: 21 Oct 2008
Location: United States
Online Status: Offline
Posts: 41
Quote tdavenport Replybullet Posted: 29 Feb 2012 at 5:57am
Thanks DBlank..I was posting before I saw your response.

I'll try that too. Always good to have a second pair of eyes on a problem.
Any and all suggestions are welcome.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Feb 2012 at 6:23am
I do not recommend the -1 trick as it only works when you definitively have the else default value ("" for text or 0 for numeric) which is giving you the extra count (+1) in your distinctcount.
the other solutions give the correct value regardless of the dataset that comes into the report at runtime.
IP IP Logged
tdavenport
Groupie
Groupie
Avatar

Joined: 21 Oct 2008
Location: United States
Online Status: Offline
Posts: 41
Quote tdavenport Replybullet Posted: 29 Feb 2012 at 7:08am
Again..thank you DBlank. That worked perfectly. It's easier to managed than my solution and, as you say, it will be accurate regardless of the data set.
Any and all suggestions are welcome.
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