You can't really teach Tableau stuff but you can program it to return the data you desire. This may be doable but I have a couple questions about your data.
Do you have time information in the date field? If not I don't think Tableau could determine which was the last CS record if both have the same date. Or if the first CS order always has a lower quantity than the second you may be able to use that to determine the correct row? Selecting CS over SA if both exist can be accomplished easily with LOD. Let me know.
I found a way around it.