title: Count occurrences of a variable having two given values corresponding to one value of another variable
body: <p>As it can be seen in the picture, I have a column with order numbers and a column with material numbers.</p>
  
  <p>I want to find how often a pair of materials occur in the same order.</p>
  
  <p>The problem is that I have 30000 rows of order numbers and 700 unique material numbers. Is it even possible?</p>
  
  <p>I was thinking if it was easier to make a matrix with the 700 material numbers both in rows and column, and count number occurrences.</p>
  
  <p><a href="https://i.stack.imgur.com/XqQoa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XqQoa.png" alt="PICTURE"></a></p>
  
  <p>EDIT: The first picture was not a good example. I uploaded this second picture with random material numbers. So I want it to count for each pair (example 10-11, as I highlighted), how many times the appear in the same order. As it can be seen, 10&amp;11 appear in 3 different orders. </p>
  
  <p><a href="https://i.stack.imgur.com/e3GEV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e3GEV.png" alt="PICTURE2"></a></p>