In your data range simply create a counter column for the variable you need to count such as this:
IF(A2=A1,0,1) This will work for all records from row 2 onwards. Simply hard-code row 1 with a 1.
A Pivot Table can then simply sum up this column to give a unique count.