Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Help with formula to show most current data Post Reply Post New Topic
Author Message
buggie
Newbie
Newbie
Avatar

Joined: 13 Aug 2009
Location: United States
Online Status: Offline
Posts: 3
Quote buggie Replybullet Topic: Help with formula to show most current data
     Posted: 17 Aug 2009 at 11:26am
< ="Content-" content="text/; charset=utf-8">< name="ProgId" content="Word.">< name="Generator" content="Microsoft Word 11">< name="Originator" content="Microsoft Word 11"><>

Hi,

 

I’m relatively new with Cystal Reports and would appreciate any help with a formula.  I am using CR 10 and my data is stored in several tables.  What I want is a report of individual services per client with diagnosis, location code and amount of service. 

 

For example:  This is the data I want.

 

Client ID         Date of Ser     Ser Cd             Amt     Diag    Loc Cd

474747            08/01/09          90862              56.00  311      CS40

474747            08/02/09          90808              47.50   311      CS40

474747            08/10/09          90806              35.40   311      CS40

474747            08/30/09          97535              45.00   311      CS40

 

My problem is for each diagnosis update I get individual services per diagnosis update.  It’s overstating the amounts per service per client.  Can anyone help with a formula to state that I only want the most recent diagnosis information.   I have already used the Select Distinct Records in Crystal but it didn’t help much.

 

For example:  This is what I get.

 

Client ID         Date of Ser     Ser Cd             Amt     Diag    Loc Cd

474747            08/01/09          90862              56.00  311      CS40

474747            08/01/09          90862              56.00   312.58 CS40

474747            08/01/09          90862              56.00   313.13 CS40

474747            08/02/09          90808              47.50   311      CS40

474747            08/02/09          90808              47.50   312.58 CS40

474747            08/02/09          90808              47.50   313.13 CS40

474747            08/10/09          90806              35.40   311      CS40

474747            08/10/09          90806              35.40   312.58 CS40

474747            08/10/09          90806              35.40   313.13 CS40

474747            08/30/09          97535              45.00   311      CS40

474747            08/30/09          97535              45.00   312.58 CS40

474747            08/30/09          97535              45.00   313.13 CS40

 

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Aug 2009 at 11:54am
Are you using SQL back end?
DO you have right sto created views or stored procedures?
IP IP Logged
Jyri
Newbie
Newbie


Joined: 19 Aug 2009
Location: Finland
Online Status: Offline
Posts: 13
Quote Jyri Replybullet Posted: 19 Aug 2009 at 1:07am
What is that "diag" field ?
 
Because if you say, that the data you want for example on date 08/01/09 is : 474747, 08/01/09,90862,56,311,CS40
 
then you should exclude diag codes 312,58 and 313,13 away from the report. Because if you have that data on your tables of course Crystal will give triple figures for you. If it won't, then it would be wrong from crystal side.
 
So just put in record : {diag}=311, then you get the data that you described.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Aug 2009 at 7:34am
I believe Diag is the Diagnosis code. Each client can have multiple diagnosis records and multiple service records with no link other than client ID between the two, hence the duplication of rows on the join. I asked buggie about the backend because it would be pretty easy to create a view or stored procedure to get the max diag joined to the client table. In the report join the view to the services and it is what is desired.
IP IP Logged
buggie
Newbie
Newbie
Avatar

Joined: 13 Aug 2009
Location: United States
Online Status: Offline
Posts: 3
Quote buggie Replybullet Posted: 20 Aug 2009 at 5:07pm
Yes, it's a SQL and the table is the correct storage are.  Like Jyri said crystal is giving the correct info but I only want the most current diagnosis code with all the other info.  
IP IP Logged
buggie
Newbie
Newbie
Avatar

Joined: 13 Aug 2009
Location: United States
Online Status: Offline
Posts: 3
Quote buggie Replybullet Posted: 20 Aug 2009 at 5:10pm
I would definitely like to learn how to make a view to obtain the max diag.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Aug 2009 at 6:11pm
In SQL you can create views or stored procedures that act the same as a table as a datasourdce for crystal. This allows you to manipulat ethe data at the source before you get it into crystal. From there you join the consumer table to the max diag view to the services table all on client number and you will not get the multiple records of your services.
Do you know how to create views in SQL or does anyone at your company/agency? If so this is a pretty straight forward view to make...
If not what version of SQL are you using and do  you have the correct SQL rights to create a view.
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