Create Duplicated Tablix Row based on Parameter - reporting-services

I'm creating report using SSRS 2016.
My report contains Tablix and each row of it will fit 1 page of paper (pdf output).
I want to add 2 parameters to accept
1. RowNumber
2. OutputQty.
Let say, my data is
ID. | Data
1 | Bird
2 | Cat
3 | Dog
If user wants to receive
- Bird 1 page
- Cat 1 page
- Dog 3 pages (copies)
ID. | Data
1 | Bird
2 | Cat
3 | Dog
3 | Dog
3 | Dog
How can I achieve that?
[edit] change example data from color to animal

I've not personally done this, but this looks like it could be of some help.
https://www.sqlservercentral.com/forums/topic/ssrs-to-multiple-pdf-based-on-input-parameters
Hope this helps.

Related

SSRS: Using tablix with multiple Dataset

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.

Creating a matrix report and linking the rows to the columns

I have this query below that works quite well generating a report like this:
Jimmy | Sword | 3
Jimmy | Axe | 0
Jimmy | Bow | 7
Alex | Sword | 1
Alex | Axe | 11
Alex | Bow | 0
Kate | Sword | 4
Kate | Axe | 6
Kate | Bow | 1
However, the powers-at-be want the PartName data across the top as columns, and then the worker and 'Total Made' count as rows for each part.
So it would look something like this:
Sword | Axe | Bow
Jimmy 3 0 7
Alex 1 11 0
Kate 4 6 1
Here is my fairly simple query that produces the first/original report:
SELECT
WorkerName, PartName,
Count(PartName) AS 'Total Made' FROM Parts_List
WHERE userID IN (select userID from warehouse1)
GROUP BY PartName, WorkerName
I figured out how to get the PartName as columns by creating a matrix and then adding a Dataset with a query like this:
select PartName From Parts_List
However, I can't figure out how to get the rows of workers and their Count(PartName) to line up with the columns.
Does SSRS even support this?
Thanks!
Using the query you have it is possible get the required matrix using this data arragement:
Add a matrix to the report surface, in Column Group add PartName column and add Worker Name to Row Groups. To show Total made add it in the below PartName cell.
It will produce this:
Let me know if you need further help.

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!

mySQL database: Separating/clustering(?) data

Currently I'm dealing with kinda large mySQL transactional database for one e-commerce project. We obtain data from e-shops including products sold. Each e-shop adds information about similarities between products and list them as groups. So, for instance shop A sends information:
Group 1: iPhone blue, iPhone black, iPhone green
Group 2: iPad blue, iPad black, iPad green, etc.
Another e-shop sends this kind of information:
Group 3: iPhone pink, iPhone black
Group 4: iPad blue, iPad pink
Each product is stored in table Products: (Important: This table has about 150 000 000 rows)
Id | Name
------------------
1 | iPhone blue
2 | iPhone black
3 | iPhone green
4 | iPhone pink
5 | iPad blue
6 | iPad black
7 | iPad green
8 | iPad pink
Also, there is a table Groups with groups stated above: (M:N relationship)
Id | Id_product | Group
--------------------------
1 | 1 | 1
2 | 2 | 1
3 | 3 | 1
4 | 5 | 2
5 | 6 | 2
6 | 7 | 2
7 | 4 | 3
8 | 1 | 3
9 | 5 | 4
10 | 8 | 4
Now, the problem is that groups 1 + 3 and groups 2 + 4 should be merged together.
Current (horrible) solution to this problem is based on obtaing all groups for the product (by GROUP_CONCAT function in query) and then all products from these groups. Then updating table groups to merge these groups into one.
Main problems with this approach are:
Very problematic computational complexity.
Groups obtained from e-shops can be wrong(!). Imagine this group:
Group5: iPhone Black, iPad Black. Taking this group into account, whole separation process is wrong. You end up with one group with iPhones and iPads together (that's wrong).
So, now, finally, the question:
Any ideas how to approach this problem? Just hints/tips will be enough, I'm just totally stuck with lack of my knowledge.
I was playing around with fuzzy-hashing algorithms / k-means clustering, but it seems to me that it is not suitable for this problem. Fuzzy-hashing seems to be getting into account names of the products (that can be good with iPhone, but cannot image it with T-shirts, their names are not very "well-prepared", so it's hard to guess differences just from the name). Am I missing something?
So, any idea?
Anyway, just for the purpose of solving this particular problem, it's possible to introduce different database solution, there's no problem in that.
Thanks in advance:)
Chmelda
An idea might be to add a table "group_conversion" which translates each external group number into your own group number.
In this case the table would look like:
Group_external | NameMatch | ID_my_group
----------------------------------------
1 | null | 1
2 | null | 2
3 | null | 1
4 | null | 2
5 | "IPhone%" | 1
5 | "IPad%" | 2
When inserting new data coming from an e-shop, you should first translate the incoming group number to your own group numbering, before adding it to the Groups table.
The NameMatch field is only used if you want to separate products whitin an incoming group (the Group5 you mentioned).
So if this field is null, just convert the ID. Otherwise only convert the ID if the name of the product matches NameMatch.
To convert your current data it might help to create a new table (e.g. Groups2) which has the same fields as Groups, with the only difference that Group is a reference to the new group numbering.
You can then fill the new table by converting each record of Groups.
After conversion is done, drop the Groups table and rename the Groups2 table.
In this way you will get a much smaller table size for Groups and the table already contains merged data, so no separate queries are needed for merging.
Hope this will help!

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.