Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Exclude original transaction Post Reply Post New Topic
Author Message
sboll
Newbie
Newbie
Avatar

Joined: 15 Nov 2007
Location: United States
Online Status: Offline
Posts: 4
Quote sboll Replybullet Topic: Exclude original transaction
    Posted: 15 Nov 2007 at 6:34am
Hello all! New member, first post.
I have a set of three transaction records. The first one was cancelled but without anything on the record that tells me so. Then there is a reversal transaction, which negates the first. And finally a reported transaction.
Excluding the reversed transaction is easy but excluding the initial transaction is my problem, especially when differentiating from initial transactions that were never reversed.

In the following, I want to exclude the first and second transactions and keep the third on account 98. But not lose account 99's one transaction.

Acct TX_ID OrigID_reposted OrigID_Rev   Amount
98      1                                   $100
98      2                         1        -$100
98      3          1                        $100

99      1                                   $150

any help would be much appreciated
Thanks
Steve
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 16 Nov 2007 at 7:06am
OK, if I'm understanding this correctly, you want to keep the data in which OrigID_Reposted = 1, and exclude the data in which OrigID_Rev = 1, and the original data, in which both OrigID_Rev is NULL and OrigID_reposted is NULL.  Is this correct?  Is this pattern always going to hold?

The SQL for something like this would look like:

SELECT AH1.*
FROM AcctHistory AH1
LEFT JOIN
    (SELECT Acct FROM AcctHistory WHERE OrigID_Rev IS NOT NULL) AH2
    ON AH1.Acct = AH2.Acct
WHERE AH1.OrigID_Reposted IS NOT NULL
    OR AH2.Acct IS NULL

This would return the third row of 98, because OrigID_Reposted isn't null, and the first row of 99, because there isn't a row where OrigID_Rev isn't null.

Unfortunately, doing this sort of thing natively in Crystal is tricky.  It doesn't support subqueries, or most tricky joins.

There is one option, if you don't mind pulling down all the data, and simply suppressing the data you don't want.

Create a group based on Acct.  Create a conditional suppression on the Details section.  The formula should look like:

Count ({OrigID_Rev},{Acct}) <> 0 AND IsNull({OrigID_Rev}

This will suppress the row if there is a reversal transaction for the account, and the current transaction is not a repost.





Edited by Lugh - 16 Nov 2007 at 7:06am
IP IP Logged
sboll
Newbie
Newbie
Avatar

Joined: 15 Nov 2007
Location: United States
Online Status: Offline
Posts: 4
Quote sboll Replybullet Posted: 16 Nov 2007 at 8:02am
Thanks for the response.

Doing this natively in Crystal, as you say, is tricky. I can do the pulling data and then suppressing unwanted data but the goal is to automate the process.

I will try the SQL statement and see how that works. The problem may be that, after talking with the customer again, they want all three records when there is a post, reversal and repost. But if there is a post and reversal, without the repost, they do not want those at all.

Wish me luck!
Steve
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.000 seconds.