title: Repeating a Function x times in the same Line in Google Sheets
body: <p>I have been researching a solution to a problem that I just can not seem to avoid, and have yet to find a solution.</p>
  
  <p>In brief, I am trying to calculate unique probabilities that lead to a "1 or 0" for more than one variable, but all in one cell.</p>
  
  <p>Here is my working code line that represents the probability of just one variable:</p>
  
  <pre><code>=sum(if(randbetween(1,100) &gt; subtotal(1,L23), 0, 1))
  </code></pre>
  
  <p>What I am trying to figure out is how to repeat this function times <code>x</code>, but with it yielding a different <code>randbetween</code> number each time, all in one cell.</p>
  
  <p>As my <code>x</code> variable can represent 10 different independent variables at this time, and stem over 30 specific formula lengths for each IV, utilizing the preset workaround would lead me to creating hundreds of cells of data. I obviously do not want that clutter.</p>
  
  <p>If code worked the way I wanted it to, the best formula-esque way I would describe what I wanted to happen is this:</p>
  
  <pre><code>=sum(repeatuniqueformula(sum(if(randbetween(1,100) &gt; subtotal(1,L23), 0, 1)), x))
  </code></pre>
  
  <hr>
  
  <p>Simplified, relevant question gathered from a problem by problem analysis:</p>
  
  <ol>
  <li>How to replicate a function in the function line that allows for the randbetween to recalculate each time.</li>
  </ol>
  
  <p>Sub-information: If you simply multiply the function by lets say 6, it will multiply the answer of the randbetween function without recalculating.</p>
  
  <pre><code>=sum(if(randbetween(1,100) &gt; subtotal(1,L23), 0, 1)*6)
  </code></pre>
  
  <p>Alternatively, I could do a workaround and create other cells with individual randbetween functions, but that causes a lot of manual work due to having to adjust the number of times a function in a line is repeated.</p>
  
  <pre><code>=sum(if(Q2 &gt; subtotal(1,L15), 0, 1),if(Q3 &gt; subtotal(1,L15), 0, 1),if(Q4 &gt; subtotal(1,L15), 0, 1),if(Q5 &gt; subtotal(1,L15), 0, 1),if(Q6 &gt; subtotal(1,L15), 0, 1),if(Q7 &gt; subtotal(1,L15), 0, 1),if(Q8 &gt; subtotal(1,L15), 0, 1))
  </code></pre>
  
  <p>The alternative is both cluttery and takes a lot of effort to maintain, as changing the number of "x" will change the amount of</p>
  
  <pre><code>if(Q2 &gt; subtotal(1,L15), 0, 1)
  </code></pre>
  
  <p>I would need.</p>