1 Reply Latest reply on Mar 2, 2016 9:01 AM by Rody Zakovich

    Filter for purchases made within first two weeks of customer's first purchase

    Brian Winkle

      Hi, I'm new to Tableau and am trying to figure out how to approach this problem. I'd like to chart purchases that occur within two weeks of each customer's first purchase. How would I do such a thing?

        • 1. Re: Filter for purchases made within first two weeks of customer's first purchase
          Rody Zakovich

          Hello Brian,

           

          Welcome to Tableau and the community!

           

          For this problem, you will want to use a Level of Detail (LoD) Expression/Calculated Field.

           

          These can get complicated, but you can refer here to get you started on them

           

          Top 15 LOD Expressions | Tableau Software

           

          For this situation, you can find the Customers first Purchase date by using a calculated filed like so

           

          { FIXED [Customer] : MIN( [Purchase Date] ) }

           

          This will return the Customer First Purchase to every record for your customer.

           

          Once you have this, you can do a simple DATEDIFF to filter on only the purchases made in the First Two Weeks

           

          DATEDIFF( 'week', { FIXED [Customer] : MIN( [Purchase Date] ) }, [Purchase Date]) < 2

           

          you can modify this as needed depending on your criteria, i.e IS the First Purchase Week 1? If so, leave the calc as is. If not change it to

           

          DATEDIFF( 'week', { FIXED [Customer] : MIN( [Purchase Date] ) }, [Purchase Date]) <= 2

           

          If you need any further explanation, please let me know.

           

          Regards,

          Rody