title: Using a measure in a filter condition in PowerPivot
body: <p>My overall goal is the following: calculate the all-time distribution of attendance across all four fiscal quarters using only data from before the current fiscal year. I have a measure that does this accurately for the current filter context. What I can't seem to manage is figuring it out for previous quarters from the current context. </p>
  
  <p>If I can calculate the all-time (pre-2015) attendance for the previous quarter, I can take it from there. I couldn't get the Date Intelligence functions to work because I had to unfilter, then refilter the year field. Here's my Quarterly attendance measure. I just can't figure out how to walk it back a quarter.</p>
  
  <pre><code>QTotal:=CALCULATE(SUM([CNF]),
   ALLEXCEPT(DateTable,DateTable[ACQuarter]),
   DateTable[ACYear]&lt;2015)
  </code></pre>
  
  <p>The next thing I tried was specifying the quarter directly in the filter. The following measure reliably calculates the previous quarter number:</p>
  
  <pre><code>PrevQ:=MOD(LOOKUPVALUE(DateTable[ACQuarter],
   DateTable[DateKey],
   FIRSTDATE(DateTable[DateKey]))-2,4)+1
  </code></pre>
  
  <p>But when I sub it into the following measure...</p>
  
  <pre><code>Test:=CALCULATE(SUM([CNF]),
   FILTER(ALL(DateTable),
   DateTable[ACQuarter]=[PrevQ] &amp;&amp; 
   DateTable[ACYear]&lt;2015))
  </code></pre>
  
  <p>...all I get are blanks. The exact same measure with a number instead of the measure works, though. I guess it's calculating [PrevQ] in the inherited ALL context instead of the unaltered filter context.</p>
  
  <p>What am I missing? Any help would be greatly appreciated.</p>