title: How can I reduce complexity? Data preparation, SQL + Tableau
body: <p>I need to prepare some data to connect to tableau, and I'm struggling because the size of the data is too much for tableau to handle, so I'm looking for ideas to code this efficiently in SQL.</p>
  <p><strong>Setup:</strong></p>
  <ul>
  <li>I have 2 million users</li>
  <li>There are 30 different categories, and each user can fall into many. For example:
  <ul>
  <li>User 1 - Category A, B and C</li>
  <li>User 2 - Category F</li>
  <li>User 3 - Category A, B</li>
  </ul>
  </li>
  </ul>
  <p><strong>What I want:</strong></p>
  <ul>
  <li>Select three categories and assign priority 1, priority 2 and priority 3</li>
  <li>These selection is not static, so today I may choose A, B, C but tomorrow those categories can be D, G, A</li>
  </ul>
  <p><strong>So if I have:</strong></p>
  <ul>
  <li>Priority 1: A</li>
  <li>Priority 2: B</li>
  <li>Priority 3: C</li>
  </ul>
  <h1></h1>
  <ul>
  <li>I want the number of users who fall into category A</li>
  <li>I want the number of users who fall into category B AND are not in category A</li>
  <li>I want the number of users who fall into category C AND are not in category A or B</li>
  </ul>
  <p>My original idea was to create a table with one row per user and one yes/no column per category, and then aggregate, but still the size of the final table is too huge for tableau to handle.</p>
  <p>Any ideas?</p>
  <p>Update: My idea is to prepare a table with aggregated numbers and a few thousand rows max, so that it can be processed with tableau</p>