I'm stuck on a formula and wondering if anyone can help?

The below formula works great, it calculates the number of times a salespersons name appears in the table. The only problem is that when I put the data into a pivot table and try to filter by week or month the filters aren't applied to this column. I think KEEPFILTERS might be what I'm after but I can't quite seem to get it working. Can anyone help?

=CALCULATE(COUNTROWS('PhoneData 1'),FILTER('PhoneData 1','PhoneData 1'[Salesperson2]=earlier([Salesperson])))