SSRS-DT 2012 Report from 2 Data Sources - reporting-services

I'm learning to use SSRS-DT 2012
I need to write a report about assets.
DataSource 1 - View that contains a relationship between a hierarchy number code (AB123) and the name of the hierarchy (Accounting)
DataSource 2 - View that contains the data about the assets and the hierarchy number (AB123).
I'd like the report to contain the Hierarchy Name and the Asset details.
I think this is a Lookup, have been getting confused on how to write it b/c in SSRS-DT you write a query as a property of a dataset (If I'm wording that correctly) - I don't know how to write a query that involves 2 data sources.
Am I missing something?

Use this expression:
=lookup(Fields!HierarchyCode.Value,
Fiedls!HierachyCode.Value,Fields!AssetsDescr.Value,"DataSet2")
As example I have these datasets:
Maybe you want to use a tablix for show this report, so I've added one with this data arrangement.
First column has Descr field of my DataSet1, the expression at right is used to join it to my DataSet2 and return the value that corresponds.
This is my expression:
=lookup(Fields!Month.Value,Fields!Month.Value,Fields!Total.Value,"DataSet2")
Note tablix DatasetName property was set to DataSet1
This will preview the following tablix:
Using the lookup function I am getting the corresponding total value from DataSet2 for every Month in the DataSet1.
For more information check lookup

Related

SSRS Multi Value Parameter

I have a report having two tab-lix and also two data set(e.g=dataset1,dataset2) for each tab-lix. When i am generating report by passing the multiple parameter location id(38,39 & 40) value if there is no record of id-38 in dataset2 i want blank space but in my report it is showing report of 39. But i want if there is no data in data set based on the parameter it is showing only blank space.Because always dataset1 having data and so it showing properly.When i am generating report with multiple parameter(38,39,40) it showing tablix1 of 38 parameter but tablix2 of 39 parameter in on page because of there is no data in dataset2 of 38 parameter.So i want to display a blank space on behalf of tablix2 if there is no data.
Give me a solution.
This answer assumes you have a table that contains all locations e.g. DimLocations, if not you should consider creating one.
You can then change your dataset query to be something like.
SELECT loc.LocationID, t.SomeColumn, t.AnotherColumn
FROM DimLocations loc
LEFT JOIN myTable t ON loc.LocationID = t.LocationID
WHERE loc.LocationID IN(#myLocationParameter)
This will ensure that you get a record for each location as long as it appears in the DimLocations table.
If this does not help, edit your question to show the dataset query you are using now and the structure of your locations table (if you have one)

SSRS report pass multiple VALUES to drill through report parameter

I created a report with 5 fields in a hierarchical order:
Order Date
Time of Day (AM/PM)
Parent Name (aka customer)
Product Line
BIC Part Number (aka Item)
Each field expands down to the next level, so order date expands to time of day, etc.
I want to create a drill through report so that the user can click on each level of the hierarchy and see the detail.
This works fine at the lowest level - Item - because only 1 values from each field has to be passed to the drill through report parameter. However, when I try, for example, to drill through based on Product Line, there will usually be 3 or 4 Items within this product line. In the Go To action, I have the drill through parameter "bic_part" set to the main report FIELD value "BIC Part Number".
I have the tablix on the drill through report set where "BIC Part Number" IN [#bic_part].
I just want to be clear, I am passing a set of report field values to the drill through report parameter, not parameter to parameter.
I have tried using expressions with =Split(Join(field value),","),",") and all variations on that. I can't seem to get the child report filters to accept multiple values from the BIC Part Number field from the parent report.
I also tried omitting the BIC Part Number value in the go to report section, but it would not let me.
All of the parameters in the child report are set to accept multiple values. My data source for both reports is the same stored proc, so I can add a query filter. I would appreciate any help.
I think each sub report link needs to be slightly different.
In the subreport, each parameter needs to accept null and your query needs to look for
(FieldName = #FieldNameParameter or #FieldNameParameter is null)
This will allow you to pass the lowest possible solid value, then null for all child values.
If we're looking at the Parent_Number level, on that subreport link you would pass Fields!Parent_Number.Value and then Nothing for each of the lower parameters (Product_Line, BIC_Part_Number).
This will allow you to filter on the lower common denominator in your sub report - Part_Number for this link, Product_Line for the next one down, etc.
I've used this logic in reports before, so it does work. Let me know if my explanation needs clarification - it's Friday afternoon..

SSRS - Look up field in dataset that is not part of report

I have an ID column in a table in my Reporting Services report. I want to title each page of my report based on a corresponding name field.
When I try to create an expression for the group-level PageName property, I see that there is a Lookup() function in SSRS. The example given in the description looks like this:
=Lookup(Fields!SaleProdId.Value, Fields!ProductID.Value, Fields!Name.Value, "Product")
The problem is that these fields are presumably in the same dataset used to create the report table. In my case, however, the name field is in another dataset of my project.
Is there a way to span report datasets to lookup up a label not in the current table's dataset?
Yes, that's exactly what the Lookup(...) function is for. The last parameter is the name of the data set that you would like to look in for your value.
From:
http://technet.microsoft.com/en-us/library/ee210531.aspx
Lookup(source_expression, destination_expression, result_expression, dataset)
Parameters
source_expression (Variant) An expression that is evaluated in the current scope and that specifies the name or key to look up. For example, =Fields!ProdID.Value.
destination_expression(Variant) An expression that is evaluated for each row in a dataset and that specifies the name or key to match on. For example, =Fields!ProductID.Value.
result_expression(Variant) An expression that is evaluated for the row in the dataset where source_expression = destination_expression, and that specifies the value to retrieve. For example, =Fields!ProductName.Value.
dataset A constant that specifies the name of a dataset in the report. For example, "Products".
Let me know if you need more explanation.

SSRS Reporting multi value parameters

I have a ssrs report, that gives me multiple product's price. My Parameter is not drill down, I have to type in the parameters(since I have large range of product number).
Now my questions is, how can i get the last entered product ( parameter) always appear at the bottom of the report ?. This would help me where to look the latest product in the report.For example I have product numbers like:
abc-234,
abc-570,
ght-908,
Now what I want is that the latest entered product number which is ght-908 to appear at the bottom of the ssrs reports. Right now it gives me the report for the multiple product, but its all over the place and i have to squint my eyes and try to find out where my most recent entered product numbers (parameters) is. I have also tried to stop the parameters to being refreshed everytime i add a product number.
Assuming your parameter name is MyParameter, in report designer (BIDS) just drop a textbox onto report below the data (e.g. Table) and put following expression into its value's formula:
=Parameters!MyParameter.Value.Split(",")(Parameters!MyParameter.Value.Split(",").Length - 1)
it will split the parameter list and grab the last value
Update: here is the screenshot with steps:
And here is the runtime result
This expression works for me:
=Trim(Right(Parameters!Product_Number.Value
, InStr(StrReverse(Parameters!Product_Number.Value), ",") - 1))
Trim might not be strictly necessary but is useful as it will work if the values are split with spaces as well as commas, or not.
For example:
It sounds like you want to order the results of the stored procedure by the order of the product codes as they are typed into the report parameter (which is a comma separated list).
You can return the index (order) of each product code in the parameter by using the Array.IndexOf and Split functions, e.g.
If you have a report parameter called "ProductNumber" and you also have a field called "ProductNumber" returned in your dataset, the following code will return the zero-based index of the Product Number as entered into the parameter list:
=Array.IndexOf(
Split(Parameters!ProductNumber.Value.ToString(), ",")
, Fields!ProductNumber.Value
)
So if abc-234 is the first product number in the parameter list then this code will return 0. If abc-570 is the second product number in the parameter list then this code will return 1, etc.
Assuming the products are listed in a tablix, then I would set the tablix sort expression to the above, which should sort the products into the order specified in the report parameter.

How to pass multiple values to a multivalued parameter in SSRS

I will try to explain the issue as best as I can by oversimplifying the report structure. Report one contains 1 group called ResourceCenter and then one line of totals under it. The totals are actually a group but the grouping is done in SQL and are presented in a detail group. The report looks something like this:
Report 1
ResourceCenter 1
Total1 11
Total2 4
Total3 8
ResourceCenter2
Total1 12
Total2 11
Total3 6
From this report, I need to drill through to another report that has a bunch of multi-valued parameters. For the drillthrough, I am able to use single values for everything except for EmployeeNumber. For that, I need to be able to pass a list of EmployeeNumbers to the multi-valued parameter in Report 2. The EmployeeNumbers are not currently present in any DataSet or parameter in Report 1 but are based on ResourceCenter. So, if the user has run Report 1 and clicks on ResourceCenter 1, I need to be able to pass a list of EmployeeNumbers associated with ResourceCenter 1 to the multi-valued parameter in Report 2 in a way that Report 2 will handle it correctly.
NOTE: I should add that I have created two SQL functions that accept an input of ResourceCenter and then return a list of employees. One is a table-valued function that returns a single column of EmployeeNumbers. The other is a scalar-valued function that returns the EmployeeNumbers as comma-separated values. I then have some custom code that runs the SQL function in the background and returns the list. I have not had any success with returning a dataset that SSRS can use but I have been able to get the scalar-valued function to 'work' in the sense that I can create a field on a dummy report and see the output. I have not had any luck getting Report 2 to accept a comma-separated list, though.
This person was doing a drill-through and appears to have solved a similar problem with a multi-value parameter. In that case it had to be formatted for an IN clause.
=SPLIT(JOIN(Parameters!SomeParameterName.Value,","),",")
If Report2 won't take it in this format, you might have to add a separate single-valued parameter that will accept a comma-separated string, which you then have to parse.
I'm using SSRS 2016, and my datasets are based on stored procedures, but passing multi-value parameters to a drill down doesn't seem to be an issue anymore. By default, when you select a multi-value parameter it gives you something like Parameters!ParName(0).Value which would pass just the first value. But if you remove the (0) and just leave it as Parameters!ParName.Value, it seems to be passing all values fine.