1 Reply Latest reply on Jul 7, 2016 8:52 AM by sbastien.konat

    How to number the purchases of each client by time

    Maxime BENOIT

      Hello everyone,


      This is driving me crazy :


      I want to number the purchases of each client of my company: P1, P2, P3...etc


      I am currently using one calculated field for each numer:

      - P1 = FIXED Id Account: MIN(Purchase Date)

      - P2 = FIXED Id Account: MIN(IF Purchase Date > P1 THEN Purchase Date)



      I gather all this with a "P" calculated field

      P= IF P1=Purchase Date THEN "P1" ELSEIF P2=Purchase Date THEN "P2" ...etc


      I have lots of data, every filter changing leads to a 5 to 10min query !


      I tried to make a custom SQL query too:



      ROW_NUMBER() OVER (PARTITION BY id_account ORDER BY purchase_date) AS purchase_number


      ... But Tableau don't get it


      I need help !


      Thanking you in advance,