SSRS 2005 Syntax for using two datasets in one expression - reporting-services

I have the following expression that works beautifully to add two values, regular hours and overtime hours.
Sum(IIF(Fields!BillStatus.Value = "F", (CDec(Fields!RegHrs.Value) + CDec(Fields!OvtHrs.Value)),CDec(0)),"ReportDataset")
What I need to do is add a third value to that, but this third value will come from a different dataset, and I cannot seem to find the proper syntax for that.
Somehow, immediately after the OvtHrs.Value, I need to say something to the effect of...
+ (Fields!HoursWorked.Value, "RBaseJobBaseline")
How do I inject that value as part of the "true" clause of the IIF, since it needs to come from a different dataset.

The only way to combine sets in SSRS it's
Lookup [msdn][1]
LookupSet msdn
MultiLookup msdn
But these functions comes to SSRS from MS SQL 2008R2 version, unfortunately in SSRS 2005 you can't do this and you should combine datasets only in data base level.
[1]: http://technet.microsoft.com/en-us/library/ee210531.aspx ????

Combine your datasets (or SQL queries) into one query.
Use the DATASETS option in SSRS2005 (via Properties of your control) to capture the "root" or main dataset by using the report aggregate functions such as FIRST(), SUM(), etc.
To report the detail of your single dataset, use the FIELDS option.
SSRS2005 can only work on ONE dataset at a time, unless you use multiple tables (or lookup parameters, etc) with different datasets, but they are still totally independant of each other.

Related

Can SSRS do excel like functions as expressions such as adding 1 cell from a column to another?

I have searched and searched but can't find the answer. I am building an SSRS report that provides a running total. I need to be able to do the equivalent of I2+J3 and have the next row be I3+J4, etc. My report uses 1 dataset. Is this possible?
Running Total Example Pulled From Excel
I found my answer. By using RunningValue function I can accomplish this task.
=RunningValue(!Fields.Charges.Value,sum,"DataSet1") creates the running total.
you can use expressions in SSRS and also use grouping. looks like a duplicate of
SSRS Expression-Sum two fields
see also
https://social.msdn.microsoft.com/Forums/en-US/74e73cd3-46ce-4812-ad15-3adc50438c04/sum-two-fields-in-ssrs?forum=sqlreportingservices

SSRS Pass parameter / Field value from 1 table to another

I am using SSRS 2012.
I have two datasets. I have two tables.
The first table contains a contract Id which is used as parameter in the second dataset.
I want to set the parameter as the contractId (ie Fields!ContractId.Value, or ReportItems!Contract1.Value) or something like that but nothing works because of different limitations.
If I would be using a subreport that would have been easy just pass the Field!Contract.Value from the 1st dataset as the parameter for the second and there you go. But since we want to call the report using SQL server agent, I cannot use subreport since the agent is limited and does not accept subreport.
So I believe my only option is to use two different tables, but I still need the value from the first dataset. Also, I don't think LookUp() would work for me as I do not have Ids.
Does anyone already did something like that?
Thanks for any help.
You can create report parameters in which the available values are pulled from a query.
Then just use the parameter in your second data set.

SSRS first function automatically added

I'm using SSRS in SQL Server 2008 with Report Builder 3.0 and was wondering, when I add a field on my report from a dataset, why does it automatically add the First() function to it ?
Instead of adding [Field] in a text box, it adds =First(Fields!Field, "Dataset")
Datasets are assumed to always be multiple rows (even though that may not always be the case). So when you drag a field to a report object that isn't meant for multiple rows - such as a textbox - SSRS needs to use an aggregate function of some sort, so that if multiple rows do come back from the dataset, the report doesn't break (since that textbox isn't made to automatically repeat itself for every row).
FIRST is chosen simply because it's least destructive; it could just as easily be SUM, AVG, or any other aggregate function.

Get data from a subreport into the main report

I have made one main report containing a few subreports. At the end I would like to compare some figures from the different parts of the report and also make some calculations with numbers received from the different parts.
Does anybody know a way to get values from the subreport into the main report? All calculations e.g. aggregates that will be made at the end refer only to the dataset for the main part and the other subreports have their own datasets, fetched from other tables.
I must second #JoaoLeal's comment, I think the method you propose (retrieving data from a subreport in the main report) is technically not possible.
However, there's another way to achieve what you want (show aggregate info on the data displayed in subreports). You could encapsulate your dataset queries in a way that they can be reused by the main report. There are two main/basic options:
Use a stored procedure to query the data
Use a database view for the data
Your datasets will be very simple: the subreports will select all the data. The main report can then either have a dataset query that aggregates data appropriately from the view / proc, or also retrieve all results and do the aggregation in SSRS.
I think in RDLC report there is no way for share variable between main report and subreport . So the only way is use another dataset or passing new vaiable. Hope this will help...
I have myself managed to achieve what I expected through using different datasets on the main form which also contains data for the sub reports.
But also I found this way (not tested):
[Reports]![YourReportName]![YourSubReportName]![TheValueFromTheSubReportYouWantToReference]
There is also a long discution about this on SQL Server Central.

SSRS IIF Syntax with Multiple Datasets

I have a report with 2 data sets and would like to perform a SUM operation in a textbox expression. The problem arises when I want to perform an IIF in the sum since I only want a particular category of values summed.
I would like to get a sum of all the "Good" ranking values from the dsRetrieveCustomerAssetScores dataset. Please note there is more than one data set in the report, so I need to specify the scope when using the aggregate function. Below is the code I've tried (along with other permutations).
=Sum(iif(Fields!ranking.Value,"Good",1,0), "dsRetrieveCustomerAssetScores")
Any ideas?
You may have more than one dataset in your report, but I don't think it's possible to have more than one dataset per tablix. (Subreports within the tablix may be bound to a different dataset, but anywhere within the subreport will only be accessing that other dataset.)
The scope specified within aggregation formulas is normally related to groups within the tablix, not the datasources.
So, the code:
=Sum(iif(Fields!ranking.Value,"Good",1,0))
- should work within your tablix, as long as that tablix is accessing the dsRetrieveCustomerAssetScores dataset.