Solved

Crystal Formula to "conditionally count/sum"

Posted on 2016-11-28
3
78 Views
Last Modified: 2016-11-28
Gurus,

I created a series of reports that include "conditional count/sum" formulas like this:

if {TBL_HISTORYTYPE.NAME} = "Client Visit Completed" then 1 else 0

Unfortunately, I recently found out that some of the records are repeating because of another table that's tied to the History table.  (CONTACT -> HISTORY -> HISTORYTYPE) (My counts are incorrect if multiple contacts are included).

I'm trying to avoid rebuilding all of these reports by adding subreports for the contact information.

Is there a way to incorporate the HISTORY.HISTORYID field (string) in the formula to only sum if the HISTORYID has changed?

Also, my "totals" have to appear in the Report Header - so I don't think a "running total" will work.

I appreciate any ideas!  Thanks in advance
0
Comment
Question by:SStroz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 41904828
You are correct that a running total won't work.

Try this

if {TBL_HISTORYTYPE.NAME} = "Client Visit Completed" then 
    {HISTORY.HISTORYID}

Open in new window


Do a distinct count on that field.

mlmcc
0
 
LVL 7

Author Closing Comment

by:SStroz
ID: 41904870
Shoot - I closed this too soon.

I should have mentioned that I have 3 formulas like this:

if {TBL_HISTORYTYPE.NAME} = "Client Visit Completed" then {HISTORY.HISTORYID}
if {TBL_HISTORYTYPE.NAME} = "Prospect Visit Completed" then {HISTORY.HISTORYID}
if {TBL_HISTORYTYPE.NAME} = "Trial Visit Completed" then {HISTORY.HISTORYID}

It doesn't look like it's counting correctly.  

It looks like Crystal is counting a "1" where there should be a "0".  ??


Any ideas?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 41905141
I was afraid that might happen.

It is counting the ones that don't match as 1 since the return is not null

Try it this way

Create a formula
Name - NULL
Formula is nothing just save an empty formula

Change the formula above to

if {TBL_HISTORYTYPE.NAME} = "Client Visit Completed" then 
    {HISTORY.HISTORYID}
Else
    {@NULL}

Open in new window


That will result in NULL for the non-matching and DistinctCount will ignore the NULLs

mlmcc
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question