SSRS - Expression using different dataset fields - ssrs-2008

I have a report with multiple data-sets. Different fields from different data-sets are used in different locations of the report.
In one part of the report, I need to do a calculation using fields from two different data-sets. Is this possible within an expression?
Can I somehow reference the data-set the field is in, in the expression?
For example, I'd like to do something like this:
=Fields.Dataset1.Field / Fields.Dataset2.Field

You can achieve that by specifying the scope of you fields like this:
=First(Fields!fieldName_A.Value, "Dataset1") / First(Fields!fieldName_B.Value, "Dataset2")
Assuming A is 10 and B is 2 and they are of type numeric then you will have the result of 5 when the report renders.
When you are in the expression builder you can choose the Category: Datasets, your desired dataset highlighted under Item: and then double click the desired field under Value: and it will appear in your expression string with the scope added.
Using same logic you can concatenate two fields like so:
=First(Fields!fieldName_A.Value, "Dataset1") & “ “ & First(Fields!fieldName_B.Value, "Dataset2")

As PerPlexSystem writes, asuming you only want to compare the first value from a dataset with values from another dataset, you can use the First function.
However, if you want to compare the values of each row from one dataset with with the values from each row of another dataset, then you will need to use a subreport - see here for further details.

Another option is to use a parameter as a variable. This is helpful if you want to create a calculated field in one of the datasets. This is best applied when the parameter value comes from a dataset with a single record.

Related

Is there a way of creating a Serial Number based on other inputs on a MS access form?

I have some samples I need to take.
In order to create a good identifier/serial number for the samples, I want it to be a product of its characteristics.
For example, if the sample was taken from India and the temperature was 40 degrees then I would click dropdowns in the form to create those two entries and then a serial number would be spat out in the form "Ind40".
Assuming that your form is bound to a table, you can create a calculated column in the table that concatenates the values from other columns into a single value.
For instance, create a new column and give it a name (for example, SerialNbr). Then for Data Type select "Calculated". An expression builder window will appear:
Enter the columns you'd like to concatenate and separate them with &. Here is an example of how the expression could look:
Left([Country],3) & [Temperature]
This expression takes the first 3 chars from the Country column and combines it with the value from Temperature column to create the value in column SerialNbr. The calculated column will automatically update when values are entered into the other fields. I'd also suggest adding another value to the calculated expression to help avoid duplicates, such as date/time of submission.

Tableau: How to display two distinct columns in worksheet, but in the filter concatenate the two columns

For example, I show two columns--CustNumber and CustName. In a filter, I would like to concatenate the two values something like this:
10100 My Customer
This would allow the user to enter either the customer number OR some of the customer's name in drop-down filter to filter by.
Thank you.
You would need to create a separate calculated field to use as the filter.
CustNumberName =
STR([CustNumber]) + ' ' + [CustName]
CustNumberName can then be used as a filter (presumably set to Wildcard Match) and the existing 2 columns can stay in the pane.
You can create a calculated field as G Hart states.
You can also create a combined field, by selecting multiple dimensions in the data pane and right clicking to Create->Combined Field. The combined field behaves very similar to a calculated field in most respects and you can easily change the delimiter or field order.
There are a few restrictions with combined fields. They can’t be used in most (or all?) calculations, nor to populate the list of possible values for a parameter. But they are easy and convenient otherwise.

Show all parameter values

My parameter field allows multiple values. How can I show all of these values at the top of the report? Currently it only shows one value at a time.
If your parameter is dynamic and takes the form of an array, you'll need to join the values together via a Formula:
Join ({?Parameter},", ")
Activate the Can Grow property for that field. Put this field in a new section so it can easily grow based on your content.

ssrs sum function in textbox

I have 2 datasets in my report. And I need to put a number of rows that meet a certain condition in a text box.
Here's what I have so far:
=Sum(IIF((Fields!OPEN_TIME.Value, "calls")=Parameters!Date.Value,1,0))
I get following error while running the report:
The Value expression for the text bix uses an aggregate expression without a scope. A scope is required for all aggregate used outside of a data region unless the report contains exactly one dataset
What do I miss?
Here if you are specifying a dataset name to a field like this "(Fields!OPEN_TIME.Value,"calls")" its a syntax error.. if you are using the field in a table which is assigned to dataset1 and table is assigned to dataset2 or field in a text box, then the field should be used with aggregate or "First", "Last"
Example:
first(Fields!OPEN_TIME.Value, "calls")
last(Fields!OPEN_TIME.Value, "calls")
sum(Fields!OPEN_TIME.Value, "calls")
Count(Fields!OPEN_TIME.Value, "calls") ...etc
In above scenario rather than taking a textbox, take a table with single cell assign the dataset "calls" to it then go for below expression:
=Sum(IIf(Fields!OPEN_TIME.Value = Parameters!Date.Value, 1,0))

I need to know if it is possible to create a SSRS report as defined

I have a query with 3 parameters that a user should be able to define:
AND (ORION_SCHED.TRIP.DATE_TIME = '09/11/2012')
AND (ORION.CUST.COUNTRY = 'BE')
AND (ORION_SCHED.TRIP.ID_SHIFT ='1')
DATE_TIME should be a datepicker
COUNTRY dropdown with defined values
ID_SHIFT dropdown with defined values
I guess this isn't an issue?
The result of this query will return the dataset
My actual question: I want the result to be presented in this way
So always 3 blocks of data next to each other, the data of every block is the result of the query filtered down on the column TRUCK_ID (a sub-select of the returned dataset)
The empty cells per block are a nice to have, these are non-unique values per TRUCK_ID that I don't wish to be repeated on every line, but like I said a nice to have.
I would add a new column to the query that returned 1,2 or 3 (for each different TRUCK_ID. Then I would use 3 Tablix (one per column on your report) and filter the data by the new column you added on the query.
Then you just group on the TruckID on each tablix and play around with the format. It should work.