Solved

Crystal Reports - Distinct field entry (not record) from select

Posted on 2006-10-30
8
8,311 Views
Last Modified: 2011-08-18
I have a minor problem I would like help with.

I am writing a crystal report that shows how records are moved to a particular area per hour. I am using a table that gives me the record number and the area it is in. The table has an entry added whenever something changes in the record so there will be multiple entries under the same area.

I currently have the report doing a distinct count of the record number in an hourly group, which works fine except that if the record gets updated later on it is getting counted again (in another hour) as the distinct count is only relevant to the hourly group. I want a way to bring in only one (the first ideally) record that shows the area in question per record number.

My select is currently by date range and record area.
0
Comment
Question by:Gryff
  • 4
  • 3
8 Comments
 
LVL 42

Expert Comment

by:frodoman
Comment Utility
You could probably write your own count formula to only count each record number once.  Something like this:

if {recordNumber} <> Previous({recordNumber}) then
  1
else
  0;

Now you can insert a sum on this formula and that should give you the distinct count.  Your data within the group will need to be sorted by recordnumber for this to work accurately.

frodoman
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
The problem as I read it is he has the data grouped by HOUR so that within a group the count is correct but he doesn't want to count a record that is updated at 8AM then again at 10AM twice.

Do you need to show the record each time it is updated or are you simply looking for a count?

If you simply want the count and don't need to see that a record was updated (but not counted) then you could select
based on the date being in range then select only the record with the minimum date in the range.

mlmcc
0
 

Author Comment

by:Gryff
Comment Utility
Hey Mlmcc,

You have the problem correctly. I simply want to count how many records are changed to this area.

How do I select the record with the minimum date?
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
Comment Utility
I don't know that you can and still get all of them in the date range?

Can you build a query or stored procedure in the database?

mlmcc
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Gryff
Comment Utility
I suppose I can write a view, I just prefer to keep things self contained where possible.

Here is what I created in case it comes up for someone else.

create view View_LTX_Area_Arrival
as
select callaudit_call_num, min(CallAudit_Last_Update) as UpdateTimeDate from sccallaudit
where callaudit_call_area_code = 'LTX'
group by callaudit_call_num
go

I used crystal to group it by the hour and to pretty it up. I never actually used the call number coming across but I anticipate the manager asking for a similar report with more detail later.

Points to go to Mlmcc as he provided sufficient information to prevent me fruitlessly wasting more time trying to do it in crystal. Thanks guys.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
You might try that same SQL as a COMMAND in Crystal.

mlmcc
0
 

Author Comment

by:Gryff
Comment Utility
I am using crystal 8.5 (stupid intranet restrictions), and I don't believe that exists in this version. thanks though
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
YOu are correct, COMMAND was added in CR9

mlmcc
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now