I have a transaction table that runs to 14th may and want to compare various metrics with the first 14 days of april. In the transaction table I have columns Date (dd-mm-yy hh:mm:ss) which comes from the database, and have calculated Trans Day (DD MMM YY), Trans Month (01 MMM YY).
My first attempt was to use transaction month as rows with the previous period calc as follows
this produced a pivot like this. I assumed that becuase my row label is actually 1st May 2012 then the DATEADD is going back to month=1st April 2012 which maps to every day in April. What is odd that for Feb & Mar11 the numbers arent the same but are for others?
<table border="1" bordercolor="#999999" cellspacing="0"><tbody><tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">Row Labels </td><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">Purchases </td><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">Prev Period Purch </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">February, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">269 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">97 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">March, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">648 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">636 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">April, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">875 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">875 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">May, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1219 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1219 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">June, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1160 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1160 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">July, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1221 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1221 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">August, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1172 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1172 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">September, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1136 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1136 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">October, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1149 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1149 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">November, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1385 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1385 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">December, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1120 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1120 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">January, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">2575 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">2575 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">February, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">2661 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">2661 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">March, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">3160 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">3160 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">April, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">3797 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">3797 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">May, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1922 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1922 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">Grand Total </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">25469 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">25285 </td></tr> </tbody></table>
I read around and found that I should have created a date table (DailyStats) so did that with Day (dd mmm yy), Monthshort (MMM) and Year (YYYY) columns. I created a relationship between transaction Day and Day. This time my measure for previous period was
This time I used MonthShort and Year as row labels. Again most months it made no differnece except Feb was differnet!! It looked like this. My expectation was that 2012 May only has days 1-14th so shouldn't April also be 1-14th? I'm really baffled by how to use time intelligent functions so would be grateful if someone could explain the principals as clearly way off track with my logic!
<table border="1" bordercolor="#999999" cellspacing="0"><tbody><tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Row Labels </td><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">Purchases </td><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">Prev Period Purchases </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">11354 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">11193 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Apr </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">875 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">875 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Aug </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1172 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1172 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Dec </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1120 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1120 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Feb </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">269 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">108 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Jul </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1221 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1221 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Jun </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1160 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1160 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Mar </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">648 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">648 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">May </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1219 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1219 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Nov </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1385 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1385 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Oct </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1149 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1149 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Sep </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1136 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1136 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">14115 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">14115 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Apr </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">3797 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">3797 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Feb </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">2661 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">2661 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Jan </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">2575 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">2575 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Mar </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">3160 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">3160 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">May </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1922 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1922 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Grand Total </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">25469 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">25308 </td></tr> </tbody></table>
My first attempt was to use transaction month as rows with the previous period calc as follows
Code:
CALCULATE(counta(transactions[Transaction]),filter(transactions,transactions[Transaction]="spend" && DATEADD(transactions[Transaction Day],-1,month)))
<table border="1" bordercolor="#999999" cellspacing="0"><tbody><tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">Row Labels </td><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">Purchases </td><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">Prev Period Purch </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">February, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">269 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">97 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">March, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">648 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">636 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">April, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">875 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">875 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">May, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1219 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1219 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">June, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1160 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1160 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">July, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1221 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1221 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">August, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1172 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1172 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">September, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1136 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1136 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">October, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1149 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1149 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">November, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1385 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1385 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">December, 2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1120 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1120 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">January, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">2575 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">2575 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">February, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">2661 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">2661 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">March, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">3160 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">3160 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">April, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">3797 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">3797 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">May, 2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1922 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">1922 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="145.5">Grand Total </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">25469 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="150">25285 </td></tr> </tbody></table>
I read around and found that I should have created a date table (DailyStats) so did that with Day (dd mmm yy), Monthshort (MMM) and Year (YYYY) columns. I created a relationship between transaction Day and Day. This time my measure for previous period was
Code:
CALCULATE(counta(transactions[Transaction]),filter(transactions,transactions[Transaction]="spend" && DATEADD(DailyStats[Day],-1,month)))
<table border="1" bordercolor="#999999" cellspacing="0"><tbody><tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Row Labels </td><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">Purchases </td><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">Prev Period Purchases </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">2011 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">11354 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">11193 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Apr </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">875 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">875 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Aug </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1172 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1172 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Dec </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1120 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1120 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Feb </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">269 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">108 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Jul </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1221 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1221 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Jun </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1160 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1160 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Mar </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">648 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">648 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">May </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1219 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1219 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Nov </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1385 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1385 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Oct </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1149 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1149 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Sep </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1136 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1136 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">2012 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">14115 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">14115 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Apr </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">3797 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">3797 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Feb </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">2661 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">2661 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Jan </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">2575 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">2575 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Mar </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">3160 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">3160 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">May </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">1922 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">1922 </td></tr> <tr><td rowspan="1" colspan="1" align="left" bgcolor="#FFFFFF" height="24" valign="bottom" width="127.5">Grand Total </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="93">25469 </td><td rowspan="1" colspan="1" align="right" bgcolor="#FFFFFF" height="24" valign="bottom" width="190.5">25308 </td></tr> </tbody></table>