title: Calculating Sub-totals as a percentage of Grand-total in Crystal Reports 2008
body: <p>I know this has been asked time and again by people all over the net, but I can't for the life of me figure out why my solution isn't working.</p>
  
  <p>I have a bunch of groups, and in each group's footer I have a running total which acts as a sub-total for that group.  At the very bottom of the page, I have a running total which adds all these sub-totals together to give a grand-total.  This all works great.  </p>
  
  <p>To the right of each sub-total (group footer), I have a formula field which calculates what proportion of the grand-total this sub-total represents.<br>
  i.e. if the Grand-total is 4, and the sub-total is 1, the formula field displays 25%.</p>
  
  <p>The problem is that for each group in the report, the Grand-total hasn't yet been fully counted (until the last group), and so the percentages are being calculated against incomplete Grand-totals.</p>
  
  <p>To combat this, I've tried using the <code>WhilePrintingRecords;</code> function on my percentage formula fields to ensure that the sub-total percentages are not calculated until the 2nd pass of the report, by which time the Grand-total should be fully calculated.  </p>
  
  <pre><code>WhilePrintingRecords;
  If {@LoggedToday} &gt; 0 Then
      {#LoggedToday}  / {#TotalLoggedToday} * 100
  Else
      0
  </code></pre>
  
  <p>It's not working though! It's literally had no impact what-so-ever :o(  </p>
  
  <p>Does anyone have any idea where I'm going wrong here?<br>
  Thanks.</p>