Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

enter image description here

I need to generate this kind of (please see the image) report in SSRS, and I wrote below 2 SQL's

  1. Active Appointments created by Online and Call center

  2. Cancelled Appointments by Online and Call center

    with cte as ( select ATS.[Description] as AppointmentSource, AST.AppointmentStatusName, Month(A.Appointmentdate) as MonthNumber, Count(A.AppointmentID) as NumberOfAppointments from Appointment A inner join AppointmentStatus AST ON AST.AppointmentStatusID = A.AppointmentStatusID inner join AppointmentSource ATS ON ATS.AppointmentSourceID = A.AppointmentSourceID where A.AppointmentDate between '01/01/2020' and '12/31/2020' AND ATS.AppointmentSourceID in (1,3) AND A.AppointmentStatusID = 1 -- Active Group by Month(A.AppointmentDate), ATS.[Description], AST.AppointmentStatusName

    UNION

    select ATS.[Description] as AppointmentSource, AST.AppointmentStatusName, Month(A.Appointmentdate) as MonthNumber, Count(A.AppointmentID) as NumberOfAppointments from Appointment A inner join AppointmentStatus AST ON AST.AppointmentStatusID = A.AppointmentStatusID inner join AppointmentSource ATS ON ATS.AppointmentSourceID = A.AppointmentSourceID where A.AppointmentDate between '01/01/2020' and '12/31/2020' AND ATS.AppointmentSourceID in (1,3) AND A.AppointmentStatusID = 2 -- Cancelled Group by Month(A.AppointmentDate), ATS.[Description], AST.AppointmentStatusName )

    select AppointmentSource, MonthNumber, NumberOfAppointments, AppointmentStatusName from cte order by AppointmentSource, AppointmentStatusName asc, MonthNumber

How to arrange the results by Month in the SSRS report ? Is there a better way to write the SQL and arrange in SSRS report?

question from:https://stackoverflow.com/questions/65830747/ssrs-report-arranging-rows-to-columns

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

Ignoring the actual SQL for now (it would be better to show the results of this rather than the t-sql)...

I think you have enough to build the report, with the exception of the Year which you don't appear to be returning. Once you have corrected this...

  1. Create a new report and create your dataset as normal
  2. Add a Matrix (not a table) to your report.
  3. Add 2 Row Groups first goruped by Year and the second (child group) grouped by AppointmentSource
  4. Add a column group, grouped by MonthNumber
  5. Choose NumberOfAppointments as the value

That's it, you should get the results as above more or less.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...