Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


expression


expression

Author
Message
cpinky01
cpinky01
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
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
Daniel Bowlin
Daniel Bowlin
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2954 Visits: 2629

=IIF(Fields!Interview_Completed.Value/Fields!Records_Included.Value = 0, "", Fields!Interview_Completed.Value/Fields!Records_Included.Value)

cpinky01
cpinky01
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
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
Daniel Bowlin
Daniel Bowlin
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2954 Visits: 2629
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.
cpinky01
cpinky01
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 120
Thanks for Replying me.
veeren4urs
veeren4urs
SSC-Addicted
SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)

Group: General Forum Members
Points: 433 Visits: 204
Hi,

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

Veeren.

Thanks & Regards,
Veeren.
Ignore this if you feel i am Wrong. ;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search