I have a table whose structure is follows:
Date
EmpID
Code
Amount
Sample data looks like this:
Date EMPID Code Amount
1-Jul-07 1 A1 100
1-Jul-07 1 B1 100
1-Jul-07 2 A1 150
1-Jul-07 3 B1 50
1-Jul-07 4 C1 120
1-Jul-07 4 D1 80
-
The Codes are not fixed, they can be of any number and varies from employee to employee.
I want to show a report like this:
Month: Jul-07 CODES --
EmpID A1 B1 C1 D1
1 100 100 0 0
2 150 0 0 0
3 0 50 0 0
4 0 0 120 80
--
Since Codes are not fixed, so an SQL query is difficult. What is the alternative approach?
I am thinking to create another table at run-time that reads column values (Code names) from the original table and create a field of that name in the next table.
I also want to know in which edition of SQL Server is reporting included. How SQL Server Reporting compares with Crystal Reports?
Secondly, while generating reports from Windows OS on a Dot-Matrix Printer, printing is slow. How can I print at a speed same as in DOS?
To answer the first part of your question:
It's a simple procedure to create a cross-tab report in Reporting Services. The dataset you'll create is nothing more than SELECT * FROM table. Next, add a List control to the form. Set the grouping to =Year(Fields!Date.Value), =Month(Fields!Date.Value) and add a Textbox control to display the month and year of the date field such as:
=Month(Fields!Date.Value) & "-" & Year(Fields!Date.Value)
Next, add a Matrix control inside the List and under the Textbox. Drag the EMPID field from the Datasets window to the Rows area of the Matrix. Drag the Code field to the Columns area. Drag Amount to the Data cell. Since the Data cell needs an aggregate function, you'll most likely do OK with the SUM function that Reporting Services adds by default. Since you have zeros in your sample above where NULL data exists, replace the equation in the Data cell with the following to display a zero instead of a blank:
=Iif(Sum(Fields!Amount.Value) <> 0, Sum(Fields!Amount.Value), 0)
No comments:
Post a Comment