In SSRS How can I do a gradual lookup? - reporting-services

I have two datasets. In each dataset it is possible to have the same item (or even string created by different columns of Dataset1 per row ) multiple times.
How can I 1) do a lookup,
2) find the first match between datasets
3) return the matching value
4) and then proceed the lookup with the remaining rows of Dataset2, instead of looking up the second row of Dataset1 with the entire list of Dataset2? .
I do steps 1-3 but I don't know how I can ensure that all items in dataset2 have been compared.
Thank you

You can use LookUpSet to retrieve all the values that match criteria from one dataset to another.
Use LookupSet to retrieve a set of values from the specified dataset
for a name-value pair where there is a 1-to-many relationship. For
example, for a customer identifier in a table, you can use LookupSet
to retrieve all the associated phone numbers for that customer from a
dataset that is not bound to the data region.
You might need to use JOIN to convert the array to a string.
=JOIN(Parameters!Status.Value, ", ")

Related

Repeat Alternating Tables per each available parameter value

I have 2 datasets for two different tables/reports. A third dataset contains available values for my parameter. Both tables use this same parameter. I want both of my tables to be repeated per available value in the parameter. I want the tables to alternate, instead of just having one table repeated x times followed by the next table being repeated the same number of times. Is there a way to do this?SSRS report snippet
I tried putting the tablix in a list and grouping the list on the parameter values. This made the tablix repeat for each parameter value, but I can't add the second table to the list since it has a different dataset. The datasets are so different that it's hard to combine them into one.

SSRS Compare Two Datasets For Missing Ids

In SSRS report I have two data sources from two different servers. I have a dataset for each data source and would like to return in a tablix the ids that are in dataset 1 but not in dataset 2.
So if dataset 1 has ids 1,2,3,4,5 and dataset 2 has ids 1,2,3 the report should display 4 and 5. I cannot link the servers. Thanks.
There are several ways to do this.
Common Lookup method
This is the way most people would probably do this
Use the Lookup() function.
Set the tablix row's hidden property to something like
=ISNOTHING(
Lookup(Fields!IDa.Value,Fields!IDb.Value,Fields!IDb.Value,"Dataset2")
) = False
The above, for clarity, assumes the ID column in dataset1 is called IDa and the ID column from dataset2 is called IDb. It will stil work if they have the same name (e.g. 'ID')
Note: Dataset name must be in quotes and is case sensitive.
Using this method returns all the rows and simply hides the ones that do not match your criteria. This may not be ideal if you're exporting the data. If not, see the alternative version below.
Alternative method
For reasonably small datasets - parameter method
... and because I thought it was an interesting approach...
This second method uses a hidden parameter and is easy to setup assuming you have a reasonable small number of records.
Using your example, create a parameter called List2 and set its default and available values BOTH to your Dataset2 query (from your example above). Make the parameter multi-value. You can make this parameter hidden once it's working.
Now Your Dataset1 query can be a simple query like this,
SELECT * FROM Table1 WHERE id NOT IN (#List2)
#List2 will contain the values from datset2 (1,2 and 3) so the query will return only the remaining values.
Note I named the datasets to match your example but the datasets must be created in the order above.

SSRS mutiple database source to be joined

Just stuck on getting information from two sources, we have a MYSQL database for repairs information which I have in SSRS, this brings back 7000 rows. We have another Repairs database in Oracle which brings back over 3 million rows.
I can't seem to bring the one from oracle as it exceeds the maximum limit, but is there any way do a left join using so i can bring only the two columns i need from the oracle one into the MySQl one which would mean i have 7000 rows plus the 2 columns from Oracle which have a common Primary key. I can't seem to join on two dataset with it being on two database.
Can anyone help.
THank you in advance
You can use the Lookup function in SSRS to find a value from one dataset based on a common key.
=Lookup(Fields!SaleProdId.Value, Fields!ProductID.Value, Fields!Name.Value, "Product")
Use Lookup to retrieve the value from the specified dataset for a
name-value pair where there is a 1-to-1 relationship. For example, for
an ID field in a table, you can use Lookup to retrieve the
corresponding Name field from a dataset that is not bound to the data
region.
(BIDs Description)
In the above example, the SalesProdID from one dataset is being used to relate to the ProductID in the Product table to get the Name field.
This will only return one value, though. This may or may not be OK depending on your data. If you need to return multiple values, use LookupSet.
=LookupSet(Fields!TerritoryGroupID.Value, Fields!TerritoryID.Value, Fields!StoreName.value, "Stores")
Use LookupSet to retrieve a set of values from the specified dataset
for a name-value pair where there is a 1-to-many relationship. For
example, for a customer identifier in a table, you can use LookupSet
to retrieve all the associated phone numbers for that customer from a
dataset that is not bound to the data region.
Unfortunately, you might need to SUM a Lookup but that isn't supported by a function in SSRS. Fortunately, users created a function for it:
SSRS Count Occurances based on multiple columns

Get value of table row

I've got two tables binded to two different datasets. I'm trying to reference one of the rows from one of the tables (Table A) from Table B.
Since it's outside the scope of the table, I can't use ReportItems![Textbox name].Value
Any ideas?
You can use the SSRS Lookup() or LookupSet() function to retrieve the data directly from the other dataset.
I found the MSDN pages a bit unclear, the syntax goes like this:
=LOOKUP(Fields!sourceMatchingField.Value,
Fields!targetMatchingField.Value,
Fields!targetReturnField.Value,
"Name of Second Dataset"
)
Fields!sourceMatchingField.Value is from the dataset that is
currently in scope.
Fields!targetMatchingField.Value is from the other data set you need to get information from and equals Fields!sourceMatchingField.Value.
These two parameter values for the Lookup function make the join criteria for the two datasets. They can be more complicated than simply two field references (such as using functions to manipulate on or both), but I'm just showing the simplest way to do it.
Fields!targetReturnField.Value is the field from the second dataset that you want to return. This should just be a reference to a field.
"Name of Second Dataset" is just what you've named the other dataset that you're joining to.

SSRS 2005 Return the parameters that do not return a matching record

I am using SSRS 2005. I have a report that has a single parameter "#Serial". Our support technicians enter computer serial numbers into the parameter field and generate a report returning the matching records from the database table. The count of serial numbers is not hard set and ranges from 1 to 100++.
My ultimate goal is to list the serial numbers that do not return a matching record.
In SSRS I have tried using the =JOIN(Parameters!Serial.Value,",") to list all of the parameter values (serial numbers) into a text field. This works fine to list ALL of the parameters passed but I do not know the correct expression to convert the list so it only contains only the un-matched serial numbers.
It was suggested that I use a Left Join in the SQL query, however, I don't know how to get the parameters entered by the technician into a temp table in SQL so that I can Join the two tables.
Any help on either method is appreciated, and alternatives to these two methods are welcome.
wouldn't you use the CountDistinct control for the parameter values