Trying to aggregate counts of a field

Bob 216 Reputation points
2021-09-01T00:14:52.83+00:00

I am creating a report to show the number of students and staff that are vaccinated. I tried just doing it in SQL and then just place the counts in the corresponding cells, but this created duplicate category rows. These results are in the image below.

128094-groupedcounts.png

The SQL in my dataset returns the counts of all vaccinated people. I should be able to enter count expressions in the 2nd column, but how do I specify which value I want to count?

128008-reporttablix.png

I figured I would add a second dataset to count people for the total population and do the same process to add them to the 3rd column.

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Isabellaz-1451 3,616 Reputation points
    2021-09-01T07:31:17.067+00:00

    Hi @Bob ,

    You can use expressions to implement this report, but it is more troublesome. In comparison, it is more convenient to use sql query. You can use this query statement to create another dataset:

    select  (select count(*) from casetest where role ='student' ) as StudentTotalCount,  
      (select count(*)  from casetest where role = 'student' and status = 1) as StudentVaccinateCount,  
       (select count(*) from casetest where role ='staff') as StaffTotalCount,  
      (select count(*)  from casetest where role = 'staff' and status = 1) as StaffVaccinateCount  
    

    here is my table

    128232-table.png

    Best Regards,
    Isabella


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.