title: Column and Row grouping in SQL Server Reporting Services 2008
body: <p><img src="https://i.stack.imgur.com/Pbwsa.jpg" alt="alt text"></p>
  
  <p>This is the desired result I need to populate as a report, where xx is number of people.</p>
  
  <p>I have a table which has fields like:</p>
  
  <pre><code>----------
  table1
  ----------
  id
  state
  year(as Quarter)
  gender
  </code></pre>
  
  <p>I need to determine the count from id and populate as a report. The year is like 20081, 20082..20084 (in quarter).</p>
  
  <p>I have created a dataset using this query:</p>
  
  <pre><code>SELECT STATE,GENDER,YEAR,COUNT(*)
  FROM TABLE 1
  GROUP BY STATE,GENDER,YEAR
  </code></pre>
  
  <p>From this query I could populate the result</p>
  
  <pre><code>ex: ca, m , 20081,3
      ny, f , 20091,4
  </code></pre>
  
  <p>From the above query I could populate the count and using group by(row) state(in ssrs). </p>
  
  <p>I need to group by (column). From the gender I get and by year.</p>
  
  <ol>
  <li>How do I take the column gender and make it has Male and Female column?</li>
  <li><p>Do I need to create multiple dataset like passing </p>
  
  <p>where gender = 'M' or gender = 'F'</p>
  
  <p>so that I could have two datasets, one for Male and One for Female?  Otherwise, is there any way I could group from the Gender field just like pivot?</p></li>
  <li><p>Should I populate result separately like creating multiple dataset for Male 2008, Female 2009  or is there any way I could group by with the single dataset using SSRS Matrix table and column grouping?</p></li>
  <li><p>Should I resolve it at my Query level or is there any Features in SSRS which could solve this problem?</p></li>
  </ol>
  
  <p>Any help would be appreciated.</p>