Since you have a Common field, It is better to join your data sources and then it would be easy for you to apply logic.
I think I can not go this route though because each data source has a different number of rows per Pidm. For example a Pidm can have 3 ActivityCodes, and 20 EventCodes.
add the TWBX the attached workbook asking for credentials
I'm sorry I cannot there is confidential data in the tableau project.