I have two datasets defined which are retrieving data from 2 databases.
For a table column, i want to simply switch between 2 datasets to pick value.
My table is retrieving data from one dataset.So for a column;
eg:
=IIF(Parameters!CompanyId.Value=40, Fields!SiteCode.Value,
SecondDataset.SiteCode.value)
How can i do that? I checked Lookup function, but I'm not sure how that is useful here?
You should be able to do it by putting the lookup in your IIF statement. Assuming the SiteCode depends on the CompanyID:
=IIF(Parameters!CompanyId.Value=40, Fields!SiteCode.Value,lookup(Parameters!CompanyId.Value,Fields!CompanyId.Value,Fields!SiteCode.Value))
If it's more complicated than this, we would need information on the table you are looking up in.
Related
I'm trying to join two data sets in my SSRS table report. The problem is that I can only concatenate two columns in my lookup statement. The third is being ignored. I need to do more than two. how can I achieve this? my values are duplicating in my drill-down report.
thanks for the help.
=Lookup(Fields!MONTH_OF_SERVICE.Value+Fields!REGION.Value+Fields!CLINIC_NAME.Value,Fields!C_MOS.Value+Fields!C_REGION.Value+Fields!CN.Value,Fields!CNT.Value,"DataSet5")
Without much more info on the datasets (data types, sample data from each dataset etc) it's difficult to offer much help.
In general though you can ...
Check that the datatypes of the corresponding fields are the same
Pad the values in in each column so they are the same width to avoid things like Month= 1 + Region = 1 matching to Month = 11 in the lookup dataset. For example if month is a number, format it to be 2 characters such as 04 for April
Add calculated columns to both datasets that will generate your lookup 'key'. The advantage of this is that you can show these temporarily in your report so you can ensure they are unique and the LOOKUP function is simpler as you will only be referencing a single field.
SSRS matrix table is a great way to generate dynamic fields as long as values exist.
However, is there a way to "always" show these dynamic fields even if a value doesn't exist for them? The report field locations varies based on data availability and users have to add missing columns in Excel manually.
Dynamic fields go from 3 to up to 30 (at least for now based on run by values). Adding these values manually would make the report hard to maintain.
The way I have handled for this is in the SQL. I build a table of all the values I will always want, I cross join that table to my final output table and update/insert values where they need to exist. That way I guarantee the rows, and eventually columns in the matrix, exists even if they end up being null.
Does that make sense?
Jesse's solution is a good one, but if for whatever reason you can't or prefer not to change the SQL you can do it in SSRS by forcing a blank value in the cell with a expression like this:
=iif(IsNothing(Fields!.xxx.Value)," ",Fields!.xxx.Value)
I have four datasets that get information for four different things (a unique set of fields for each one), but that can be joined using a field they share. I need to get them all into a tablix that will have four rows, one for each dataset per the linking field. How do I do that?
Currently I can only put in values from one dataset.
Often the best idea would be to create a query that joins the datasets in the sql. If that is not possible, you can look into using the Lookup function to find info from other datasets in your report. The related Lookupset function is able to retrieve sets of information and may be useful as well.
I want to get data(dynamic) according to the data in another dataset and put the result in textbox of the different dataset.
Right now, the data I get is static and I tried to use many expressions but no avail.
Problem lies in editing textbox expression. Since I am getting data from different dataset, it always ask me to have dataset aggregate function in my expression. If I specified the dataset from where I am getting the data, then, I cannot make it dynamic - and I get the undesired result.
And another way out that I attempted is merging the data sets into one rather than having multiples and use it only but this was unsuccessful.
How can I make it work to get the result that I want:
By the way, the textbox and the tables are in different scope. I have tried to combine them in one scope too.
Getting data from another dataset requires an aggregate function because it can't tell what data you want from that dataset so it forces you to aggregate it so it can return a specific value rather than an entire list of values.
I think what you are after is the Lookup function. Lookup allows you to look up a value from another dataset based on a value in the table's dataset. To give a simplistic example, let's say your table was of employees and you had a department id on that table and another dataset called "Departments" which had an id and a name. You could look up the department's name using the following expression:
=Lookup(Fields!DeptId.Value, Fields!Id.Value, Fields!Name.Value, "Departments")
This uses the current table's dataset's DeptId field to look up the Departments dataset by the Id field and return the Name field.
=Lookup(First(ReportItems!EmpID.Value),Fields!EmpID.Value,Fields!Dept.Value,"dataset_which_u_retrieve_the_data_from")
Problem solved!By using reportItems instead of Fields because I am retrieving one data only,not the whole field.
Thanks guys for helping me out.
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.