how do i make addition of two fields in ssrs expression? - reporting-services

I have generated one ssrs report
now i have two fields having values
1st field value is =Fields!FirstNO.Value
2nd field value is =Fields!SecondNO.Value
now i have one field average and i need to write expression like
average = (Fields!FirstNO.Value+Fields!SecondNO.Value) / (Fields!SecondNO.Value)
how can i write above in expression?? directly as i shown or any other syntax is there please help?

Are you sure these fields are numeric? Maybe try convert to numeric, like =cint(Fields!FirstNO.Value)

Related

MS Access Expression That Includes Dynamic Field Names

I have a crosstab query which returns results based on consumer demand for a bunch of material numbers. The material numbers become my field names in the crosstab query, and later the values from those fields are displayed in a form.
In the form, I display the value in a textbox. There are a couple of these textboxes where I need to sum the total of two or more values from these fields. Not a big deal it's a simple expression. For example (in the Control Source property): =[H123457] + [H123456].
This works well UNTIL there is no demand for a particular material number. In this case, the field doesn't show up in the crosstab query and I'm left trying to sum two fields where one doesn't exist.
I've tried IIf(IsError([H123456]), 0, [H123456]), Null expressions, Nz function, etc but cannot figure out how to dynamically solve the #Name issue that ends up populating the text box.
Essentially what I want is for a 0 value for the field that doesn't exist, so I can add it to the value where the field DOES exist - is this possible?
Regards!
June7 provided the answer in the allenbrowne.com link. Essentially, you need to add all of the possible field names to the Column Headings property in the crosstab query property window. Then it's a simple matter of adding an Nz() function to handle null values.
Thanks June7!

Filter Multivalue Parameter on Dataset

So I have a multiple value parameter than contains 3 options. >250K, <250K, >2M.
I also have a table that consists of multiple columns.
. Because the parameter is a multivalue, i am having difficulties filtering the dataset.
I need to filter the dataset by checking, (if > 250K is selected, filter the dataset accordingly), (if < 250K is selected, filter the dataset accordingly) and (if > 2M is selected, filter the dataset accordingly).
I was told to use a join and split on the parameter within the (>250K condition, then do a contains to see if it contains any of the parameter values) but I am not as advanced in my knowledge of coding to be able to do that.
Any Suggestion? Thanks in Advance
I previously tried the method below but then i came to realise that it wont work because the parameter is a multi value.
I know its been a while since you raised this, you were on the right track but all you should need to do is add a filter to the Tablix on the field you will be filtering, use the 'in' operator and in the Value type [#Yourparametername] the square brackets and case sensitivity are important. Also ensure the expression type is correct, in your case it looks like you are using Integer. The image should help.
If you want to use multi-parameters, In the dataset, you can read parameter value using JOIN.
Example:
If you want to read multiple values for #MyParamter in a dataset given in the following example:
Dataset Parameters
you need to use =JOIN(Parameters!myMultiParamter.Value,",") as an expression to read all selected values in CSV form.
Expression
Now the #ParameterValues param has all selected values as comma separated values and you can use them in your dataset code as per design requirements.
Note: It's not necessary to use a comma but u can use anything you want to separate values.
Your sql query where should look like
Where
(
(0 IN (#Parameter) AND ValueColumn<250000)
OR
(1 IN (#Parameter) AND ValueColumn>=250000)
OR
(2 IN (#Parameter) AND ValueColumn>=2000000)
)
One parameter
Two parameters
All parameters
Once you return the value you can also use charindex or patindex* and look for where the value in your where clause is a pattern where the index number is > 0 . For instance if the returned string from SSRS is '01,02,03' and then your where clause has something like this right(field, 2) which would result in value '03'. you change your where clause to be where patindex('%' + right(field, 2) + '%', #returnedstring) > 0 which will give you results. The keeps you from having to parse apart the #returnedstring parameter in your sql code.

how to get last date between two dates SSRS

For Example i have two Parameters of Date
first: 1/21/2016
Second: 4/21/2017
I want to get second date.Is it possible through any SSRS Expression?
Yes. Assuming that the names of the parameters are First and Second, then you can access the values using the following expression.
=Parameters!First.Value
=Parameters!Second.Value
You can use this type of expression for any parameter, of any type, as long as you know the name.

SSRS report with muliple datasets

I have added a separate dataset to an SSRS report...it contains some similar tables as another dataset. When I go to write expressions the fields in my new dataset have a "SUM" in front of the field numeric fields and "First" in front of the char fields??? Now I can't pick the numeric field for my report because it will "SUM" up all the data
Just remove the SUM() portion once you add the field. Perhaps it is there because of the scope of the bound item. There is no harm in removing the aggregate if the field is in a position in which a detail can print SUM(X)=X.
To follow on the heels of Ross' answer...
You can remove those [SUM(FIELD)] tags from your table by clicking it and hitting delete. To add the single data value you want to display, type the field name in brackets like [FIELD] right into that text box.
Alternately, edit the expression the be:
=Fields!YOURFIELDNAME.Value

Simple sum in a calculated control MS-access

Trying to get the sum of three fields and enter it in a fourth text box on the same report. For a particular report,
empnose =78
empright=555
empleft= 565
The total text box should be 1198
using the expression
=Sum([EmpNose] And [EmpRight] And [EmpLeft])
the result is -4
using the expression
=Sum([EmpNose]+[EmpLeft]+[EmpRight])
the result is 226514940
using the expression
=([EmpNose]+[EmpLeft]+[EmpRight])
the result is 78555565 (the three values concatenated)
What is the correct syntax?
If you want to add up the values of the current record only, Sum() is wrong, because it sums over all records.
=([EmpNose]+[EmpLeft]+[EmpRight])
should be correct. If it concatenates the values it seems your fields are text fields instead of numbers?
If you can't change the datatypes to numbers, you can try
=(Val([EmpNose]) + Val([EmpLeft]) + Val([EmpRight]))
The Val() function tries to convert a string to a number.