CADF_to_nth_purchase_allrows inputs CADF data and the desired purchase number that you want to count the nth result of.
Useful links