ssrs sum function in textbox - ssrs-2008

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))

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.

Group data based on different size

I am trying to make a report in which I need to show data based on Width groups. Below is an example of data & the required output. I'm unable to make a group which can give this required output. If someone can help please.
The easiest way to accomplish your grouping needs for this data set would be to create a new Formula Field that evaluates the values of the Width data field for each record to determine which group the record belongs within, then do the grouping on this new formula field.
You formula field will look like this.
Select {WIDTH}
Case 400 to 600 :
"G1"
Case 601 to 849:
"G2"
Case 850 to 1049:
"G3"
Default :
"Default text or error message text goes here"
You will likely need to adjust the integer values I'm used in the Case statements to evaluate the WIDTH field. The text that goes into the Default case is up to you. In fact, if it works logically with your needs, you could eliminate the Default case entirely, as it is not required. However, it is good practice to ensure the Switch statement always returns a value, even if that value is text to indicate that something unexpected occurred. This allows your users to easily recognize a bit of a data that may be out of range for the grouping of the report so the report can be modified or the data can be corrected, whichever is the most appropriate action.
The other 3 columns in your required output appear to just be counting the number of records within each group that have a diameter within a range. To get this output you can use Running Total Fields with a Type of summary of Count and then use the range of values in the Evaluate section. The Reset section will be set to On change of group evaluating the group created by the formula field above. You will want to put a sort order on the diameter field though.

Fix the "Cannot mix aggregate and non-aggregate arguments with this function" error when creating a calculated field

I need to create a Dimension (calculated field) that depends on a filter.
My dataset has four columns: ID (Int), Variable Name (String), Value (Int) and Client ID (String). For each client ID there will be a value for each type of variable.
There are 6 types of Variable Name, and for each row there is unique ID.
I'm using a filter by Variable Name so there is one, and only one variable type available at the same time.
In order to display it in a stacked bar chart by that dimension, I have created this calculation field (In reality if has six IFs, but I'll use just one to illustrated it):
IF ATTR([1 (ML_Output)].[Variable Name])= "Interest Rate" THEN [Interest Rate] END
That way, when the filter is in "Monthly Interest Rate", the ATTR function should show the only type of variable available in the Variable Name field, which would be "Monthly Interest Rate". The problem is that it shows the "Cannot mix aggregate and non-aggregate arguments with this function" error.
I've been trying to solve this with many tutorials, but none of them work for one reason of another.
Any ideas?
EDIT:
PS: The original calculation that was doing what I wanted used a Parameter. However, since parameters won't update automatically when the dataset changes, I can't use it anymore. The original calculation was:
IF [Parameter 1]="Interest Rate" THEN [Interest Rate] END
I need the calculated field as a dimension. So, if I aggregated the result of the calculation, then it would be a measure, and that can't be used to create a stacked bar.

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.

SSRS - Expression using different dataset fields

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.