title: DAX Measure to Calculate Percentage of Customers with New Purchases Within One Year Sliding Window
body: <p>I need a measure that will give me the percentage of customers during a calendar year who had new purchases within one year of their last purchase.</p>
  
  <p>Normally I would just create a calculated column that captured the date of each customer's last purchase for each year, and then check to see if each customer from a given year had any purchases within a year of their respective last date, and then sum those up, but I'm using a live connection to a cube and can't create calculated columns.</p>
  
  <p>Here's some pseudo-code of what I'm looking for:</p>
  
  <pre><code>One Year Return =
  VAR Cohort =
  SUMMARIZECOLUMNS (
      Customer[ID],
      FILTER (
          VALUES ( Sales[Sales Date] ),
          YEAR ( Sales[Sales Date] )
              &lt; ( YEAR ( TODAY () ) - 1 )
      )
  )
  VAR Returners =
  SUMMARIZECOLUMNS (
      Customer[ID],
      FILTER (
          VALUES ( Sales[Sales Date] ),
          Sales[Sales Date] &gt; Sales[Old Sales Date]  //&lt;--Need help here 
      ),
      FILTER (
          VALUES ( Customer[ID] ),
          Customer[ID] IN Cohort
      )
  )
  VAR Rate =
  CALCULATE ( DISTINCTCOUNT ( Customer[ID] ), Customer[ID] IN Returners ) /
  CALCULATE ( DISTINCTCOUNT ( Customer[ID] ), Customer[ID] IN Cohort )
  RETURN
      Rate
  </code></pre>
  
  <p>The main difficulty is that I need a different time window for each customer, but can't make a calculated column. I've been looking at using EARLIER or DATESBETWEEN or PARALLELPERIOD, but haven't been able to get any of them to work so far.</p>