user2332678
user2332678

Reputation: 31

SSRS or SQL Numbers Rounding/Truncating In SSRS Report

I am using SSRS to write a report and I am running into a very strange issue. I have numbers that are rounding that I do not want to round.

Below are the expressions that are in play. I have formatted the textbox to display 4 decimals, default, money, custom, and others with no luck. The numbers have the correct decimals to begin with.

So below are the expressions I am using.

Why are the results rounding or truncating when the OR operator is used????

New to SSRS and SQL in general.

Textbox1 has this Expression in it

IIf(Fields!SelQty.Value=1,Fields!EstPrice1.Value * Fields!Qty1.Value,0)

Results

2252.2800,
191.3205,
505.2300,
240.8000`

Textbox2 has this Expression in it

IIf(Fields!SelQty.Value=2,Fields!EstPrice2.Value * Fields!Qty2.Value,0)`

Results

81500.0400,
5914.0800,
58166.1600

Change Textbox1 to this Expression =

IIf(Fields!SelQty.Value=1,Fields!EstPrice1.Value * Fields!Qty1.Value,0)

OR

IIf(Fields!SelQty.Value=2,Fields!EstPrice2.Value * Fields!Qty2.Value,0)

Results

2252,
191,
505,
241,
81500,
5914,
58166

Upvotes: 0

Views: 1334

Answers (1)

gbn
gbn

Reputation: 432311

OR here is a bitwise operator

So 2252.2800 OR 0 gives 2252 because of some type casting. Personally, I've never bitwised numeric numbers so don't know how it works

Why use OR anyway: it makes no sense with Iifat all. What are you really try to do?

Nested Iif like this?

=IIf(
       Fields!SelQty.Value=1, 
       Fields!EstPrice1.Value * Fields!Qty1.Value,
       IIf(
             Fields!SelQty.Value=2, 
             Fields!EstPrice2.Value * Fields!Qty2.Value,
             0
           )
     )

Upvotes: 1

Related Questions