Answers.Body: <p>Just do a <code>{% set myEntries = craft.entries.whatever.find() %}</code> to load the entries into an array. Then do two loops, the first to get whatever totals you want, the second to display the players stats. </p>
  
  <p>Yes, you're doing two loops. But you're only hitting the database once to load into the array, which is where the performance bottleneck will be unless there are a ton of entries. </p>
  
  <p>In any event, wrap it all in a cache tag. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-06T22:10:01.923Z
Answers.Text: Definitely thought I would be doubling my calls, looks to have no affect. This'll do!
Answers.UserDisplayName: Chase Giunta
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-05T23:13:00.713Z
Answers.LastActivityDate: 2015-12-05T23:13:00.713Z
Answers.UserDisplayName: andrew.welch
Body: <p>Currently I’m looping through some results on an athlete’s bio page to get their individual win/loss record… Something like <code>{% if matchWon is defined %}{% set wins = wins + 1 %}{% endif %}</code> is looping in a table of their records. This works great, and will accumulate their record just fine, but what if I want to show the athlete’s record ​<em>​*before*​</em>​ the table where all that logic is run? Any way to display those final win/loss values out earlier in the dom?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-05T22:55:36.947Z
Comments.Text: Can you post a bit more of your template code? i.e. where you're retrieving your results and grabbing matchWon.
Comments.UserDisplayName: Brad Bell
Tags: <variable><math>
Title: Minor math in template, display result before logic in DOM
ThreadText: # Minor math in template, display result before logic in DOM
  
  (Asked by: username_0 on 2015-12-05)
  
  Currently I’m looping through some results on an athlete’s bio page to get their individual win/loss record… Something like `{% if matchWon is defined %}{% set wins = wins + 1 %}{% endif %}` is looping in a table of their records. This works great, and will accumulate their record just fine, but what if I want to show the athlete’s record ​*​\*before\*​*​ the table where all that logic is run? Any way to display those final win/loss values out earlier in the dom?
  
  **Tags:** variable, math
  
  > **Comments:**
  > **username_1**: Can you post a bit more of your template code? i.e. where you're retrieving your results and grabbing matchWon.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-12-05. Score: 3 | Accepted answer
  
  Just do a `{% set myEntries = craft.entries.whatever.find() %}` to load the entries into an array. Then do two loops, the first to get whatever totals you want, the second to display the players stats.
  
  Yes, you're doing two loops. But you're only hitting the database once to load into the array, which is where the performance bottleneck will be unless there are a ton of entries.
  
  In any event, wrap it all in a cache tag.
  
  > **Comments:**
  > **username_0**: Definitely thought I would be doubling my calls, looks to have no affect. This'll do!  
  
  ---
  
  