There are 2 Tables on Two Different Servers,
I Have Dataset1 pointing to Server1.
Similarly I have Dataset2 Pointing to Server2.
Now I want to Use some Values from Dataset1 in Dataset2.
Dataset1:-
Select * from Table1
This has Name,Lessthan,GreaterThan
Dataset2:-
Select * from TableX X inner join Dataset1 on Dataset1.name=TableX.name
Where X.Time>Dataset1.Lessthan and X.Time>Dataset1.GreaterThan
Have tried doing the same as above but we are not able to Access the contents of Dataset1 in Dataset2
It Throws error As 'Invalid Object :-Dataset1'
Please guide me on this.
You're right: a Dataset's query can't access another Dataset: the query is sent to the database server, which knows nothing of your other Dataset which is defined in the report only.
You can make some report parameters (which can be hidden from the user), which use your Dataset 1 to provide their values.
Then you can pass the parameter values to Dataset 2: when you open Dataset 2's properties you will see 'Parameters' on the left. In Dataset 2's query, include things like #paramvalue, and you will be able to supply it with your values from your report parameters.
Related
Scenario: I am working with a Firebird database (somewhat similar to MySQL) connected to Microsoft SSRS 2012 via ODBC connection manager.
I have a huge stored procedure (which I am not supposed to modify at all) given by our client. The stored procedure has a parameter - Parameter X filtering Column X (integer datatype); when I pass values to Parameter X - say 1,2,3,4... individually, I am able to run the report correctly in SSRS.
However, when I try to pass a string of values - (1,2,3,4...) - i.e. (by checking) 'Allow multiple values' for this Parameter X (text datatype) in SSRS Report Parameter Properties box, I get this error -
'Cannot add multi value parameter '?' for dataset XYZ because it is
not supported by the data extension. (XYZ is the main dataset for this report)
The values 1,2,3 are passed as input from another dataset (PQR).
How can I pass multiple input values (1,2,3,...) to Parameter X from this PQR dataset ?
As I have mentioned, I cannot modify the PSQL Firebird stored procedure (main dataset XYZ) at all. The procedure reads something like this for filtering Column_X:
WHERE :Parameter_X CONTAINING Column_X
Now if :Parameter_X = 1 or 2 or 3 individually passed from dataset PQR, SSRS report works fine.
If :Parameter_X = (1 ,2, 3, ....) multi values passed from dataset PQR, SSRS report throws the above error.
I can modify the dataset PQR, but not the main dataset XYZ.
Any suggestions ?
Join(Parameters!ParameterX.Value,",") still works. In my case it was using OLE DB connection type instead of regular ORACLE in Report Manager.
It seems OLE DB could not parse Join(Parameters!ParameterX.Value,",") .
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
In an existing SSRS 2008 r2, report, I am attempting to add a parameter called 'Customer_Category'. I am getting the following error message:
The report paramter 'CustomerNumber' has a DefaultValue or a ValidVaue that depends on the report parameter 'Customer_Category'. Forward pointing dependencies are not valid.
I am trying to determine how to fix this error. The 'CustomerNumber' is a parameter value that is obtained by reading from a dataset. In this dataset there are existing other parameters called 'Customer_Type' and 'Customer_Preference'. Both of these parameters obtain there values from selections that the user makes when the SSRS report is executing. There are no default values.
I am trying to have the 'Customer_Category' be the same way where there are no default values and the user must select the parameter value when the report is executing. There should only be one value that the user can select from.
The new parameter called 'Customer_Category' is the last parameter in the list of parameters. Does the order of parameters make a difference? If so, how can I move the 'Customer_Category' parameter in front of the customer_number parameter?
Here is the sql that is used from obtaining a list of customers from the dataset for customer_number:-
SELECT Distinct CustomerNumber
FROM BridgeUserCustomer
WHERE
Type = #Customer_Type
AND Preference = #Customer_Preference
AND Category = #Customer_Category
GROUP BY CustomerNumber
Would you tell me what is wrong and what I can do to solve the problem?
Summary
The order of parameters in your IDE (Report Designer or Report Builder) matters.
If you have a hierarchy of parameters (one level dependent on the other), the top-level parameter must appear first in the parameter list.
In SSRS these are referred to as cascading parameters.
Solution
Open the Report Data tab
Expand the Parameters folder
Select a parameter and use the up/down arrows to adjust order
Report Designer
Report Builder
I have 2 tables which both have the column "countyID"
I have a main report that brings up reports based on a query like:
SELECT countyID, name, address, state
FROM TableA
---I have a parameter set on TableA where you select the Name to view its report.
I then have a second report based on a query like:
SELECT *
FROM TableB
I want to use the second report as a subreport, as in, when you select the Name for the top report it should then list all records from TableB with the same CountyID.
Is there a way to set countyID as a parameter and then pass it to the subreport? This way the subreport would always only return records with matching countyID's to the currently selected record of the main report.
I'm assuming that you've created a drop-down #Name parameter to load into the DataSet you're using for TableA. You've configured this Parameter to specify its values from the Name field of your TableA DataSet, which likely uses a query similar to:
SELECT CountyID, Name, Address, State
FROM TableA
WHERE Name = #Name
You would then need to create another parameter to store the relevant CountyID values from that DataSet, e.g. #CountyID. Set it to 'Hidden'. For the Available Values and Default Values, point it to the same TableA DataSet, but have it use the CountyID field for its values/labels.
You'd then need to pass the #CountyID parameter into your subreport. The DataSet for this tablix should be, like you outlined:
SELECT *
FROM TableB
WHERE CountyID = #CountyID
Are you sure you're using a subreport for this, and not just another tablix? The reason being, if you are using a subreport, you would need to open the subreport report object and create the #CountyID parameter on there as well, assuming that is where the TableB DataSet is. Set it to Hidden but don't worry about setting any values, since it will received from your Main report.
Lastly, go back to the original Main report, right-click on the subreport box that you dragged onto your report body, and go to Properties > Parameters > Set Name to CountyID , and the Value as [#CountyID] .
**Note: In SSRS, parameters have the annoying trait of being case-sensitive. It's always good to keep this in mind sooner rather than later in report development.
Currently have three subreports, one main report.
Main report has two parameters - SELECTDATE and EMP_ID. Main report sends Order_Nbr to all subreports.
All subreports work perfectly when I only select 1 Employee and 1 date, but if I choose multiple values it blows up.
SQL has the column as an INT. I have both parameters in main report and subreport, SELECTDATE is set as Text with Multiple Values, and EMP_ID is set to Integer with Multiple Values. My queries has my date IN (#SELECTDATE) and emp_id IN (#EMP_ID).
It obviously sends the correct information to the subreports because it works, but I would like it to work with more values being passed. Love the current ability to check and uncheck employees and end of month dates, like it currently is set using the IN function in my query.
Make the Parameters on your sub report non-multivalue, remove any 'Available values' set.
Pass the multivalue parameter from you parent report as a string using the join method
=Join(Parameters!Emp_ID,",")
The EMP_ID parameter will be set to a comma delimited list, which is what a multivalue parameter sends to the query
I'm not sure how this works with text queries, but it works with stored procedures.
If the sub report is also used as a stand alone report you will need to add a new parameter to allow the user to send parameter values to #Emp_Id from a parameter the user can set
I guess you have not set the parameter in the sub report as Multi Select. If you have set the parameter in the sub report as multi select, then you could just send the parameter from the main report to the sub report as it is. See more at here
I used the following solution, which works in SSRS2016. This also works with text parameters.
Like suggested above, pass the parameter as a string to the subreport by JOINing the values.
Join(Parameters!EmpID, ",")
In your subreport, accept the parameter as text.
In the SQL of your subreport, use the string_split function of SQL 2016 to return a table of the values and simply join it to your main query. So basically if your parameter is named "EmpID_Multi" do
... JOIN (SELECT value FROM string_split ( #EmpID_Multi, ",")) mv ON mv.value= ...
Note: You might consider pulling the values into a temporary table for SQL optimization (sometimes the optimizer does funny things...).