Nitheesh Reddy
Nitheesh Reddy

Reputation: 34

Addition of two field values in SSRS report expression

I am trying to add two report fields in a placeholder expression in SSRS reports:

= SUM(Fields!TOTPRICE.Value) + SUM(Fields!TAX.Value)

But when I run the report i am getting error in the placeholder value.

Here is How I created the DataSource to the report

enter code here     <DataSources>
<DataSource Name="DummyDataSource">
  <ConnectionProperties>
    <DataProvider>SQL</DataProvider>
    <ConnectString />
  </ConnectionProperties>
  <rd:DataSourceID>ef567ff-88fd-ef88f8f2b6b4</rd:DataSourceID>
</DataSource>

Here is how I created Dataset to the report:

 `enter code here`  <DataSets>
<DataSet Name="CStore_POReport">
  <Fields>
    <Field Name="IDOBJECTNAME">
      <DataField>IDOBJECTNAME</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="CDEACCOU">
      <DataField>CDEACCOU</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="NMEREQUE">
      <DataField>NMEREQUE</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="FLDTXTCONTACTPHONE">
      <DataField>FLDTXTCONTACTPHONE</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="NMECOMPANY">
      <DataField>NMECOMPANY</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="FLDTXTPOBOX">
      <DataField>FLDTXTPOBOX</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="NMESTREET">
      <DataField>NMESTREET</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="NMECITY">
      <DataField>NMECITY</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="NMESTATE">
      <DataField>NMESTATE</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="FLDTXTZIP">
      <DataField>FLDTXTZIP</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="NUMQTYORDER">
      <DataField>NUMQTYORDER</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="DSCITEM">
      <DataField>DSCITEM</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="CURUNITDOLLARS">
      <DataField>CURUNITDOLLARS</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="TXTUNITOFMEASURE">
      <DataField>TXTUNITOFMEASURE</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="TOTPRICE">
      <DataField>TOTPRICE</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="NUMTAXT">
      <DataField>NUMTAXT</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="TXTCOMMENTS">
      <DataField>TXTCOMMENTS</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="TAGTAX">
      <DataField>TAGTAX</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="NUMREQ">
      <DataField>NUMREQ</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="DTECREATED">
      <DataField>DTECREATED</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="TAX">
      <DataField>TAX</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="CRNCYID">
      <DataField>CRNCYID</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="CRNCY_SYMB_TXT">
      <DataField>CRNCY_SYMB_TXT</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="ITEM_CLS_CD">
      <DataField>ITEM_CLS_CD</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="ITEM_CD">
      <DataField>ITEM_CD</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
  </Fields>
  <Query>
    <DataSourceName>DummyDataSource</DataSourceName>
    <CommandText />
    <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
  </Query>
  <rd:DataSetInfo>
    <rd:DataSetName>CStore</rd:DataSetName>
    <rd:TableName>POReport</rd:TableName>
  </rd:DataSetInfo>
</DataSet>

https://i.sstatic.net/JYjdG.png

Upvotes: 1

Views: 13619

Answers (3)

Nitheesh Reddy
Nitheesh Reddy

Reputation: 34

Finally Got to know the solution for this ... i m surprised how many people had the same issue an yet there is not one post which can clearly explain the solution for this..

I've found two workarounds for this problem:

1) Changing Target Framework from 4.0 to 3.5 in the project settings

2) Adding the following line inside the web.config in the system.web section:

<trust legacyCasModel="true" level="Full"/>

Upvotes: 0

Aftab Ansari
Aftab Ansari

Reputation: 946

Can you check these options if it works

1.Try with = SUM(VAL(Fields!TOTPRICE.Value)) + SUM(VAL(Fields!TAX.Value))

2.Make sure that your query is populating all the required columns

3.Make sure that your query has same column header name as you have mentioned in the report under tag. For example if you have defined TAX but your query return the column header as tax/Tax, it might create issue because RDL backend is XML and case sensitive.

Upvotes: 2

Silagy
Silagy

Reputation: 3083

Try this.

= CStr(SUM(CInt(Fields!TOTPRICE.Value)) + SUM(CInt(Fields!TAX.Value)))

Ok i think your problem occurres due to which both of your fields' type are string, so before you can perform an add operation you need to convert them to integer

You need to convert the result to string in order to present it in the placeholder

I have created an example for you, First the QUERY

enter image description here

Next the report in edit mode enter image description here

Has you can see i am presenting the TOPPRICE in the first column and the TAX in the second column and i wrote an expression for the third column

= CStr(CInt(Fields!TOTPRICE.Value) + CInt(SUM(Fields!TAX.Value)))

This is the results

enter image description here

Upvotes: 2

Related Questions