SSRS: Using tablix with multiple Dataset - sql-server-2008

I have two datasets:
My First dataset (Students) looks like this:
Student_Name| ID
Jack Luis | 1
Adam Bob | 2
And my second dataset (Exam) looks like this:
Student_ID | Exam | Note
1 | Java | 15
1 | Php | 14
2 | Java | 12
2 | Php | 13
I want to get this in the same Tablix:
Student Name | ID
Jack Luis | 1
Adam Bob | 2
Student_ID | Student Name | Exam | Note
1 |Jack Luis | Java | 15
1 |Jack Luis | Php | 14
2 |Adam Bob | Java | 12
2 |Adam Bob | Php | 13

Thank You Mr alejandro zuleta
but i want the result like this in the same Tablix (using groupin By Name)
Studant Name:Jack Luis
Exam | Note
Java | 15
Php | 14
Studant Name:Adam Bob
Exam | Note
Java | 12
Php | 13

I think this can be solved using LOOKUP function. LOOKUP function joins multiple dataset using a common field in the involved datasets.
Create a tablix and set the DataSetName property to your second dataset.
Drag and drop the fields to the columns you want to show. For the Student Name column use the following expression:
=Lookup(Fields!Student_id.Value,Fields!Student_id.Value,Fields!StudentName.Value,"DataSet21")
In the above expression replace DataSet21 by the actual name of your
first dataset.
It will preview something like this:
UPDATE: Grouping by a header row.
Add a tablix and set your second dataset in DataSetName property. Add Exam and Note fields to the corresponding columns.
Add a Parent Row Group.
In the Tablix group window select the Add group header checkbox and use the following expression:
=Lookup(Fields!Student_id.Value,
Fields!Student_id.Value,Fields!StudentName.Value,"DataSet21")
Delete the first column created by the previous grouping setting.
In the cell above Exam use the following expression:
="Student Name: " &
Lookup(Fields!Student_id.Value,Fields!Student_id.Value,Fields!StudentName.Value,"FirstDataSet")
Now select Exam and Note row and add a row above outside the group.
Type Exam and Note in the corresponding cell above [Exam] and [Note] fields.
Select the three cells in the first row, right click it and select Merge Cells.
It will preview something like this:
If you want to delete the first blank row, you can do it smoothly.
Let me know if this helps.

Related

Access: Using table data in one column as field names in another table

Okay, I have one table that is a list of items. I want that list of items as field names for another table. I want to be able to add to the list, easily, which will, in turn, add new field names/columns to this other table. Example:
Table 1
ID | Name
1 | Bob
2 | Paul
3 | John
Table 2
ID | Bob | Paul | John
1 | y | n | y
You shouldn't store the data like the second table. It isn't normalised and will lead to a whole world of pain further on. You should store that data something like;
ID | PersonID | Value
1 1 y
2 2 n
This will be easier to query and won't require a re-design when Harry arrives.
You can create a crosstab query to display it like your example.

Show distinct id once with multiple rows of data

What I have for data:
Bob | 1
Bob | 2
Bob | 3
Jane| 5
Jane| 27
Basically I want to sort this out in either the query or report so I can come out with this as a result:
Bob | 1
| 2
| 3
Jane| 5
| 27
Do I have to use VBA to come up with this solution or is there a workaround either in the query or in the report functionality? I'm just getting used to using Access, so I'm looking for some pointers.
For those that are looking in the future, I had multiple other columns of data that correlated to the one 'name' I wanted to separate out. If you sort by group, you can make the name the 'group name' and all the values will still correlate to that group if you leave them under your details tab in the report.

SSRS Single row for Grouping

I'm working with SharePoint Lists, I have 2 Lists for this issue i.e. Movies & Theatres. Only one list is used tough, because Theatres reference a movie.
(I know this is weird but I'm not actually working with movies and theatres, it's just using an analogy so anyone could understand the problem so let's assume each Theatre only plays a single movie :-P )
So from the Theatres list I create a dataset with following fields: Linked_Movie (Title), Country, Theatre_Number.
I want to create a report that shows a tablix that lists all Movie-titles with all the countries it's shown in and a count of the theatres that are playing that movie. So the tablix should look like example below:
MovieTitle | Country | # of theatres
| |
Movie 1 | Country A | 5
| Country B | 10
SubTotal | 2 | 15
| |
Movie 2 | Country C | 15
SubTotal | 1 | 15
| |
Total | 3 | 30
I have already created a tablix which groups on Linked_Movie first and Country second. Then in the details-section I just count the theatres that play that certain movie in that specific country. To achieve this I created a second dataset with the exact same data so I could use LookUpSet.Length. But even though my calculations are correct the tablix still generates a row for each individual theatre. So my tablix actually looks like example below:
MovieTitle | Country | # of theatres
| |
Movie 1 | Country A | 5
| | 5
| | 5
| | 5
| | 5
.... | ... | ...
So if anyone knows how I would be able to achieve a tablix like the first example that would be greatly appreciated.
If anything is still unclear please don't hesitate to ask.
Kind regards
Gravinco
I was able to solve it by adding a calculated field to the dataset named MovieCountry.
After this I put the expression below as the condition for 'Row visibility' and the visiblity of the '=(Details)' properties:
=iif(Fields!MovieCountry.Value = Previous(Fields!MovieCountry.Value), True, False)
This way I only get a single row for each movie and country combination.
Any questions are always welcome!

SSRS: Using lookupset to get multiple fields

I have two datasets:
My main dataset (Students) looks like this:
Student Name | PID
Anakin SkyWalker | 1
Obi-Wan Kenobi | 2
And my second dataset (Awards) looks like this:
PID | Xtrnl_Award_Type | Xtrnl_Award_Date
1 | BS | 200912
2 | BA | 200605
2 | MS | 200905
What I want to get is this:
Student Name | Awards
Anakin SkyWalker | BS - 200912
Obi-Wan Kenobi | BA - 200605, MS - 200905
The LookupSet function can only return one field in the second dataset. Is there some other way I can get the results I want? The second dataset is on another server.
You can use an expression as the target Dataset field:
=Join(LookupSet(Fields!PID.Value
, Fields!PID.Value
, Fields!Xtrnl_Award_Type.Value & " - " & Fields!Xtrnl_Award_Date.Value
, "Awards"), ", ")
Works for me based on your data:
I just realized I can get what I wanted by adding a calculated field to my second data set that combined the two fields.

How do you get the records from single dataset to display onto 4 corners of landscape page? [SSRS]

I am using Microsoft SQL Server Reporting Services 2005
I have a report that when printed I want to display a record in each of the 4 corners of a landscape page.
I am using a single Dataset that returns 1 to many records.
How do I accomplish this with a table or matrix?
For example if I had 6 records in my dataset:
Page 1
|---------------------|
| record 1 | record 2 |
|---------------------|
| record 3 | record 4 |
|---------------------|
Page 2
|---------------------|
| record 5 | record 6 |
|---------------------|
| [empty] | [empty] |
|---------------------|
So I have found a successful way to do this (with help from cdonner's suggestion), have 2 identical table templates and have one display all odd records and the other to display all even records.
This is what Design Mode looks like:
|-------------------|
| table 1 | table 2 |
|-------------------|
Then, what I did was on each tablerow of each table added the expressions to the Visibility > Hidden property of the tablerow:
For Odd Rows:
=RowNumber(Nothing) Mod 2 = 0
For Even Rows:
=RowNumber(Nothing) Mod 2 = 1
The only way I can think of is by using subreports, one showing all even rows, the other one showing all odd rows.
To add Groups to Jon's answer, place tables 1 and 2 within a parent table which performs the grouping:
table-parent
group-row-header // header text..?
group-row-footer // group name is important for below
rectangle
table-child-1 | table-child-2 | etc // =RowNumber("my-group-name")
Note RowNumber must be based on the group so that it resets with each loop.