Finding values which is coming net to zero
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I have multiple transactions from salary and I have to figure out the pair which is sum is not equal to zero
From the example below: Salary Id;123 => 7000+(-7000) = zero-> Eliminate (could be multiple transaction with same value pairs)
Salary Id 123 => 7200+7000 + 2000+8800 = 25000 (which is equal to salary amount) -> Keep it
Same goes for Salary Id 789 => 789 => -2500 + (-2500 )= -5000 (which is equal to salary amount) -> keep it
Note: The Idea is to eliminate the pair which is coming as zero (which is opposite to each other and should be pair)
salary_Id | Transaction | salary |
123 | 7000 | 25000 |
123 | 2000 | 25000 |
123 | 7200 | 25000 |
123 | 7000 | 25000 |
123 | -7000 | 25000 |
123 | 7000 | 25000 |
123 | -7000 | 25000 |
123 | 8000 | 25000 |
456 | 3800 | 8800 |
456 | 5000 | 8800 |
789 | -2500 | -5000 |
789 | -2500 | -5000 |
Output:
salary_id | Transaction | salary |
123 | 7200 | 25000 |
123 | 7000 | 25000 |
123 | 2000 | 25000 |
123 | 8800 | 25000 |
456 | 3800 | 8800 |
456 | 5000 | 8800 |
789 | -2500 | -5000 |
789 | -2500 | -5000 |
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I suggest the following:
Create a RecordID grouped by salary_id and transaction amount
Create a Key field of salary_id and abs transaction amount
Join the positive and negative transaction and eliminate matched ones (same key and RecordID)
Keep just the unjoined records
Should produce the set of results you want
Sample attached
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
If you can help me -
I need the output netting to zero from 2 or more than 2 rows:
Find amounts which net to zero with same ID
Find amounts which net to zero irrespective of ID
