Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Record Selection Formula, Should be simple,yet not Post Reply Post New Topic
Author Message
Eric
Newbie
Newbie
Avatar

Joined: 31 Jul 2008
Location: Canada
Online Status: Offline
Posts: 7
Quote Eric Replybullet Topic: Record Selection Formula, Should be simple,yet not
    Posted: 02 Sep 2008 at 11:05am
Been trying to make this very simple report for a while now and I cant get CR to filter the report the way I need it to!  And this is a 3 table, dead simple report.

Table #1 = STOCK (holds all details from our stock, uses primary key STM_AUTO_KEY)
Table #2 = ADJUST (holds an STM key and details of adjustments)
Table #3 = TRANS (holds an STM key and details of adjusments)

Tables #2 and #3 hold the same information about costs & quantity adjustments, but depending on how it is done in the software a single adjustment could be stored in table #1 or #2 or both!

So I created this selection formula which seemed to work fine...

IF    {STOCK.STM_AUTO_KEY} = {STOCK_ADJUST.STM_AUTO_KEY}
AND {STOCK.STM_AUTO_KEY} = {STOCK_TRANS.STM_AUTO_KEY}
THEN  {STOCK_ADJUST.COST_ADJ} <> {STOCK_TRANS.COST_ADJ}

The problem is that I still have several hundred double entries If there's more than 1 adjustment for that stockline (STM_AUTO_KEY) it cannot intelligently match the COST_ADJ fields to eliminate the doubles...  So if 4 adjustments are done a certain way, you could have 4 entries in ADJUST and 4 entries in TRANS.  Then CR cannot mismatch these....

Any ideas?
E. Tremblay
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 03 Sep 2008 at 12:45am
Hi,
 
When you add three tables you will see crystal creates a Links Tab in Database expert ,Have you linked the three tables,if yes what do you want to display in the report then ,Also if you post some sample data it would be nice.
 
 
cheers
Rahul
IP IP Logged
Eric
Newbie
Newbie
Avatar

Joined: 31 Jul 2008
Location: Canada
Online Status: Offline
Posts: 7
Quote Eric Replybullet Posted: 03 Sep 2008 at 7:00am
Of course the tables are linked, I have been using CR for almost 2 years now. This report seemed simpled at first...  I'll post some more table info...

[STOCK]
- STM_AUTO_KEY (primary key for the table & left outer join from this field to the two others)
- All other fields contain stock info and arent important for the report

[STOCK_ADJUST]
- SAJ_AUTO_KEY (its own primary key)
- STM_AUTO_KEY
- CHANGE_DATE
- COST_ADJ
- QTY_ADJ

[STOCK_TRANS]
- STT_AUTO_KEY (its own primary key)
- STM_AUTO_KEY
- CHANGE_DATE
- COST_ADJ
- QTY_ADJ

Im filtering all the stocklines that are in either of the "STOCK_XXXX" tables with the COST_ADJ field.  So that field must contain an amount in either table, this way I can calculate total cost adjustments of our stock daily, monthly, etc...

I noticed that depending on the adjustment, the same information can be inserted in both the TRANS & ADJUST tables. So I added this filter...

IF    {STOCK.STM_AUTO_KEY} = {STOCK_ADJUST.STM_AUTO_KEY}
AND {STOCK.STM_AUTO_KEY} = {STOCK_TRANS.STM_AUTO_KEY}
THEN  {STOCK_ADJUST.COST_ADJ} <> {STOCK_TRANS.COST_ADJ}

Find the double entry and if the cost is the same remove one... this didnt work too well but it did filter out about 20,000 stocklines out of 250,000.

Here's some typical data Im getting right now...
STM_KEY   SAJ_KEY     STT_KEY      COST_ADJ
123456           280              162350          168.13           
123456            280              162451          168.13           
123456            174933          280              168.13           
123456           174934          280              168.13         
123456          175035          280              168.13 
123456            280               280             168.13

This example shows that it looks like the cost adjustments was done 6 times, but it was only done once.  When looking in the software, the tables would look like...

ADJUST table & TRANS table
- Adjusted cost 168.13
- Adjusted quantity +3
- Adjusted quantity -1

I just need a filter that will grab the cost_adj field once in either table per transaction.  I've tried getting it to compare dates, cost, keys...  I always end up getting double entries....

E. Tremblay
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.015 seconds.