1

I have two cloumns in ssrs

1. Column10

Expression(column1 + column2 + column 3)

2. Column11

Expression(column4 + column5 + column 6)

Now I want to subtract column 11 from column 10

I am doing now

 =(Fields!column1.Value) + (Fields!column2.Value) + 
 (Fields!column3.Value) 
 - 
 (Fields!column4.Value) + (Fields!column5.Value) + 
 (Fields!column6.Value)

Is there any wrong with this approach. Any other better way to do this.

Virender Thakur
  • 327
  • 3
  • 12

2 Answers2

2

Your expression is incorrect. It is only subtracting Columnr4 - you need to use parenthesis around the entire part that is being subtracted.

 =(Fields!column1.Value + Fields!column2.Value + Fields!column3.Value) 
  - 
  (Fields!column4.Value + Fields!column5.Value + Fields!column6.Value)

I try to use as few parenthesis as possible to avoid errors like this.

I don't like using Report Items. You could create two calculated fields in the dataset - one for the Column 10 and one for Column 11 that has the expression for each.

Column 10:

=(Fields!column1.Value + Fields!column2.Value + Fields!column3.Value) 

Column 11:

=(Fields!column4.Value + Fields!column5.Value + Fields!column6.Value)

enter image description here

Then your expression for Column 12 would be

=Fields!column10.Value - Fields!column11.Value
Hannover Fist
  • 10,393
  • 1
  • 18
  • 39
1

=Me.ReportItems("txtColumn11").Value - Me.ReportItems("txtColumn10").Value

In the double quotes, is the name of the textbox.

When it's possible, I prefer doing most calculations in the query so there is less business logic in the report expressions.

aduguid
  • 3,099
  • 6
  • 18
  • 37