title: Flattern data by count
body: <p>I have some data like this:</p>
  <pre><code># of jobs  count
  ---------  -----
  1          2
  2          3
  3          1
  4          1
  </code></pre>
  <p>They represent a <a href="https://en.wikipedia.org/wiki/Multiset" rel="nofollow noreferrer">multiset</a> {1, 1, 2, 2, 2, 3, 4}. I want to do statistics (medium, mean, mode) against the multiset. Is there any way to somehow generate this list from the 4x2 data above? That way I can use the built-in functions (<a href="https://support.microsoft.com/en-us/office/median-function-d0916313-4753-414c-8537-ce85bdd967d2" rel="nofollow noreferrer"><code>MEDIUM</code></a>/<a href="https://support.microsoft.com/en-us/office/average-function-047bac88-d466-426c-a32b-8f33eb960cf6" rel="nofollow noreferrer"><code>AVERAGE</code></a>/<a href="https://support.microsoft.com/en-us/office/mode-function-e45192ce-9122-4980-82ed-4bdc34973120" rel="nofollow noreferrer"><code>MODE</code></a>). Currently I’m using <a href="https://support.microsoft.com/en-us/office/sumproduct-function-16753e75-9f68-4874-94ac-4d2145a2fd2e" rel="nofollow noreferrer"><code>SUMPRODUCT</code></a> to calculate mean, and a combination of <a href="https://support.microsoft.com/en-us/office/max-function-e0012414-9ac8-4b34-9a47-73e662c08098" rel="nofollow noreferrer"><code>MAX</code></a>/<a href="https://support.microsoft.com/en-us/office/match-function-e8dffd45-c762-47d6-bf89-533f4a37673a" rel="nofollow noreferrer"><code>MATCH</code></a>/<a href="https://support.microsoft.com/en-us/office/index-function-a5dcf0dd-996d-40a4-a822-b56b061328bd" rel="nofollow noreferrer"><code>INDEX</code></a> to get the mode, but I can’t figure out a way to calculate medium.</p>
  <p>Note:</p>
  <ol>
  <li>Of course the real data is much more than 4 rows, but the idea should be the same.</li>
  <li>The first column is sorted integers, if that helps.</li>
  <li>It’s OK to use some auxiliary cells to hold intermediate data.</li>
  <li>It doesn’t have to be a formula; if pivot table is a better tool, please advise.</li>
  </ol>