I have a fact table with each row representing these key pieces of information
- Serial Number
- Activity Type (Shipment, Return, Claim)
- Activity Date
- Account Name
A serial can have MANY events over its life. For instance
- Shipped to _
- Returned from _
- Shipped to _
- Claim from _
- Return from _
- Claim from _
- Shipped to _
- Claim from _
The challenge here is that I need to check if every instance of that was a valid transaction based on prior transactions. For instance:
- A return is only valid if it matches the last shipped account
- A claim is only valid if it hasn't been returned and the claim matches the last shipped account.
What I have been able to do so far is create reports as of the latest ship event for that serial. Essentially ignoring everything else.
What I can't figure out is how I would create a full year report that captures ALL possible violations though the course of the year. Keeping in mind that I have thousands of serials I need to run this report for.
In other words using my example above, I can easily identify #8 as valid/invalid, but how would I create a report that also says the status of #4 and #6? And then do this for every serial. I'm sure this type of problem has come up frequently, but I haven't been able to find resources to similar issues.