Here’s an example of one way to achieve the results you want. There might be more efficient ways, but I find this way pretty easy to read too:
$yesterdays = Import-Csv -Path ("05-07-2014.csv") $todays = Import-Csv -Path ("05-08-2014.csv") $getquota = "05-08-2014_Add_Quota.csv" compare-object $yesterdays $todays -Property EMPLID,GROUP_NAME -PassThru | #Group by the employee id in order to compare old and new group names Group EmplId | #To make working with additional clauses (e.g. the where-clause) easier, let's #create an object with the Old and New entries as different properties Foreach { New-Object PSObject -Property @{ New = $_.Group | Where { $_.SideIndicator -eq '=>' } Old = $_.Group | Where { $_.SideIndicator -eq '<=' } } } | #Then just filter the list to get the ones you want Where { $hasChangedFromFacultyToStudent = $_.Old.Group_Name -eq 'FacStaffStudents14Spring' -and $_.New.Group_Name -eq 'Students14Spring' $hasChangedFromStudentToFaculty = $_.Old.Group_Name -eq 'Students14Spring' -and $_.New.Group_Name -eq 'FacStaffStudents14Spring' #In this case we only want those that did _not_ change according to either of the two above conditions return -Not($hasChangedFromFacultyToStudent -or $hasChangedFromStudentToFaculty) } | #You seem to only care for the new data, so lets throw away the old data Select -ExpandProperty New | #And then select the properties you want Select * -ExcludeProperty MIDDLE_INITIAL,SideIndicator | #And finally export the CSV Export-Csv $getquota -NoTypeInformation