Tablix report with multiple tables linked together - reporting-services

I want to create tablix report in the following format:
Where Customer / Orders / Inquiries are seperate tables with customer ID as primary key. How can I create this kind of tablix report where I can display all information in single row by customer ID?
Link to the report format

If you don't want to create one dataset that joins all the tables together you could create multiple datasets one for customer, orders, and inquiries and use the lookup and lookupset function by passing in the CustomerID to each.
You would paste expressions that look similar to these in the textboxes of the table
Lookup(source_expression, destination_expression, result_expression, dataset)
LookupSet(source_expression, destination_expression, result_expression, dataset)
=JOIN(LookupSet(Fields!CustomerID.Value, Fields!CustomerID.Value, Fields!OrdersthisQuarter.Value, "orders"),"")
=JOIN(LookupSet(Fields!CustomerID.Value, Fields!CustomerID.Value, Fields!InquiriesthisQuarter.Value, "inquiries"),"")
=Lookup(Fields!CustomerID.Value, Fields!CustomerID.Value, Fields!Contact.Value, "orders")
=Lookup(Fields!CustomerID.Value, Fields!CustomerID.Value, Fields!Region.Value, "inquiries")
Lookup Function reference
LookupSet Function reference

You need to write a query that joins all the tables and creates a data set. I would recommend using stored procedure for your query.
Add data set & data source to SSRS.
Create the tablix report.
Please make your data set does not return to many rows because it will complicate browsing & export performance.
More details: http://msdn.microsoft.com/en-us/library/dd220592.aspx

Heres a reference to creating a dataset in SSRS. SSRS Dataset
I"m assuming you're query and the embedded dataset code would look something like this if you join on cusotmerID:
SELECT customerID
,customername
,contact
,region
,ordersthisquarter
,inquiriesthisquarter
FROM Customer C WITH (NOLOCK)
JOIN Orders o WITH (NOLOCK) ON c.CustomerID = o.CustomerID
JOIN inquiries i WITH (NOLOCK) ON i.CustomerID = c.CustomerID
if you paste this as a dataset you can use the fields from this dataset on a tablix.
When you build your table, create a group on customer ID and that should roll up to one customer and will display the multiple orders and inquiries they have. creating groups

Related

how to manipulate SSRS multiple values parameters in a dataset

i have a simple ssrs report in which i have one multiple values parameter.
I want to use the returned values to execute some queries on another table, but when i create the second dataset and i try to get the list of returned values i get ssrs error.
Example:
Multiple values parameter: #MyParam1
Anthony
Michael
Mary
I want to select for example only the values that starts with 'M' and populate with the filtered data another multiple values parameter called #MyParam2.
When i try to parse #MyParam1 in my dataset query i get the error because teh returned value is an array type. I read on some blogs that i can use the JOIN function , but how i can use directly in the Dataset TSQL code?
thanks a lot!
You could use the original table for the parameters and filter it by your selection for your main query.
SELECT FIRST_NAME, USER_LAST_NAME, USER_ID
INTO #TEMP_USERS
FROM USERS
WHERE FIRST_NAME IN (#MyParam1)
Then JOIN on the TEMP table to filter for the parameter selections and add your criteria.
JOIN #TEMP_USER U ON U.USER_ID = X.USER_ID AND U.FIRSTNAME LIKE ('M%')

Lookup using textbox value as source showing too many rows + SSRS

I did a lookup function in ssrs where the source is a reportItem reference. I want to return the value from the table that I am looking up based on the reportItem reference. The report is retrieving the correct values, but and I'm getting repeated rows and I'd like to know if there's a way to eliminate that. My parameters in the tablix is based on a ticket number.
The underlying data has 3 transactions but 9 rows are currently being returned.
In SSRS, my query is:
Select
ticketno, name, control, value
from ticket a
inner join details b on a.ticketno = b.ticketno
where control like 'LS%' and ticket = 'ED08'
The return result contains 4 rows transactions
ie:
Ticket
Name
Control
Value
ED08
Eng
LS1
A
ED08
Acct
LS2
B
ED08
Med
LS3
C
In SSRS, I used a table and hard coded the Name as it's possible that there will be no values.
I hard coded Eng, Acct, Med, Dent for names.
I entered an expression on each individual row with an expression
=lookup(ReportItems!textbox.Value,Fields!Name.Value,Fields!Value.Value, "UDF_Det")
However, when I run the report, I get extra rows.
The transactions retrieved from the ticket in SQL only retrieved 3 rows, so I would have expected that. Is there a way to filter on row specific data?
I have looked at this post Adding values to a Report when there is no Data in query SSRS but since I am not doing any calculations I'm not sure why I am getting repeat rows.
My design looks like this:
Output looks like this:
Acually, now I've edited your question I understand the problem. :)
You can just get a list of Name and left join from it to your existing query.
You maybe able to get the list from an existing table (hopefully) or you could hardcode one (avoid if possible).
Assuming all the Names you need are in your ticket table you could use something like this...
SELECT DISTINCT [Name] FROM ticket
(if name comes from another table, just change the query to suit)
then left join your existing query to this, something like
SELECT n.[Name], t.ticketno, t.control, t.value
FROM (SELECT DISTINCT [Name] FROM ticket) n
LEFT JOIN (
Select ticketno, name, control, value
from ticket a
inner join details b on a.ticketno = b.ticketno
where control like 'LS%' and ticket = 'ED08'
) t
ON n.[Name] = t.[Name]
which should give you something like
Name
Ticket
Control
Value
Eng
ED08
LS1
A
Acct
ED08
LS2
B
Med
ED08
LS3
C
Dent
NULL
NULL
NULL
Then you can simply have one row in the detail group in your table to output the results.
If this does not help, post some sample data from your database tables and show the full report design including row groups etc

Replacing Foreign Key with Reference Name from other table in SSRS report

I am creating an SSRS matrix report in which Loans are mapped with primary keys of Employees originated the loan, so the tables looks like:
<table><tbody><tr><td>LoanID</td><td>Employee</td></tr><tr><td>101</td><td>1</td></tr><tr><td>102</td><td>2</td></tr><tr><td>103</td><td>3</td></tr><tr><td>104</td><td>2</td></tr><tr><td>105</td><td>1</td></tr><tr><td>106</td><td>2</td></tr></tbody></table>
<table><tbody><tr><td>Employeeid</td><td>Employee Name</td></tr><tr><td>1</td><td>A</td></tr><tr><td>2</td><td>B</td></tr><tr><td>3</td><td>C</td></tr></tbody></table>
When I create the matrix using first table I get:
<table><tbody><tr><td>Employee</td><td>Count Of Loans</td></tr><tr><td>1</td><td>2</td></tr><tr><td>2</td><td>3</td></tr><tr><td>3</td><td>1</td></tr></tbody></table>
But I wanted result like:
<table><tbody><tr><td>Employee</td><td>Count of Loans</td></tr><tr><td>A</td><td>2</td></tr><tr><td>B</td><td>3</td></tr><tr><td>C</td><td>1</td></tr></tbody></table>
How can I relate the name of values in rows groups to take out the names of Employees?
It is generally better to join tables in the source system when you can. To answer your question, you can use the Lookup function to get the Employee Name from the second dataset. In this case it would look something like this:
=Lookup(Fields!Employee.Value, Fields!EmployeeID.Value, Fields!EmployeeName.Value, "DataSet2")
In other words, for each row, it is looking up the employee ID in the second dataset and returning the name.

VB.NET, MySQL & Crystal Report comparative statement between two tables

My two MySQL tables have different information but one field is common. I am showing you the structure of two tables.
I need to show it in a single report filtering by cust_id.
i.e. Customer Id wise billing and payment report.
I tried...
SELECT * FROM billing_info as a,payment_info as b WHERE a.cust_id='1' AND b.cust_id='1' AND a.cust_id=b.cust_id
but rows are repeating.
Hope I explained this properly. Now what should I do ?
Is it possible in Crystal Report to show two tables data ?
I guess ur table structure may resulting duplicate entries.
in table payment_info instead of using the cust_id (reference of cust table), u should use id of table billing_info so that we will get more precised output for ur query.
U also get payment details agains which bill has been made.

SQL Server Report Filter Expressions

So I have two datasets called Employee and EmployeeData. Employee is the main dataset that is used by the report and I want to add a filter to it. The filter parameter is created as EmployeeID. Employee has columns Name, Department, Job, etc. EmployeeData has columns Name, EmployeeID, Address.
I'm trying to filter using EmployeeID on Employee so I need to do some sort of join with EmployeeData using Name as the key. This would be easy in SQL but since I'm new to SSRS, I don't know what the syntax of the expression would look like here.
Thanks
Create another parameter #employeename and set it's default value to the employee name from the employeename dataset, then use that parameter to filter the Employee dataset based on the like operator and the name field.
SSRS is very sensitive to parameter order, so you may need to delete and recreate them in the correct order.