Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

expression Expand / Collapse
Author
Message
Posted Wednesday, September 15, 2010 8:52 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, January 02, 2013 6:36 PM
Points: 52, Visits: 120
Hi,
In one column I am calculating this.
=Fields!Interview_Completed.Value/Fields!Records_Included.Value
This is the percentage.
When this is 0% IT HAS TO BE BALNK. MEANS IT SHOULD NOT SAY 0%. How can we write an expression in ssrs for this?
Thank you
Post #986345
Posted Wednesday, September 15, 2010 1:31 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, April 14, 2014 2:16 PM
Points: 2,812, Visits: 2,543

=IIF(Fields!Interview_Completed.Value/Fields!Records_Included.Value = 0, "", Fields!Interview_Completed.Value/Fields!Records_Included.Value)
Post #986617
Posted Wednesday, September 15, 2010 4:27 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, January 02, 2013 6:36 PM
Points: 52, Visits: 120
Hello, thats what i wrote. but i needed something different.it is like this.when the denominator is zero it is displaying "Nan"
i dont wnat this way in the report.

I have an expression like this in ssrs. It display nothing when
(Fields!Survey_Completed.Value)/(Fields!Email_Invite_Sent.Value)=0
But and value when the result of this is some value. But I wanted to have nothing whne the denominator is zero.
Can anyone help me with this?
The expression that I have now is this which does not displays what I want.
=iif((Fields!Survey_Completed.Value)/(Fields!Email_Invite_Sent.Value)=0," ",(Fields!Survey_Completed.Value)/(Fields!Email_Invite_Sent.Value))

thank you
Post #986776
Posted Thursday, September 16, 2010 7:16 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, April 14, 2014 2:16 PM
Points: 2,812, Visits: 2,543
Try this instead
=IIF(Fields!Records_Included.Value = 0, "", IIF(Fields!Interview_Completed.Value/Fields!Records_Included.Value = 0, "", Fields!Interview_Completed.Value/Fields!Records_Included.Value))


Or if you use this kind of calculation a lot, many of us do you could go to Report>>Report Properties and choose the Code tab and put something like this function in there:
Public Function DivideBy(ByVal Exp1, ByVal Exp2)
If Exp2 = 0 Then
DivideBy = ""
Else: DivideBy = Exp1/Exp2
End If
End Function

Then in your SSRS expression you would put
=code.DivideBy(Fields!Interview_Completed.Value, Fields!Records_Included.Value)

and it would all work out just fine.

PS. I found this function code either on this site or elsewhere on the internet. I found it extremely useful and it is now part of my report template.
Post #987218
Posted Thursday, September 16, 2010 4:42 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, January 02, 2013 6:36 PM
Points: 52, Visits: 120
Thanks for Replying me.
Post #987812
Posted Wednesday, September 22, 2010 1:37 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, March 21, 2013 5:54 AM
Points: 433, Visits: 199
Hi,

Custom code gives u more accurate results in your requirment pinky.

Veeren.


Thanks & Regards,
Veeren.
Ignore this if you feel i am Wrong.
Post #990910
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse