Solved

Crystal Formula to "conditionally count/sum"

Posted on 2016-11-28
3
93 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 101

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 101

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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

630 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