SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Average issue


Average issue

Author
Message
ekknaveen
ekknaveen
SSC Veteran
SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)

Group: General Forum Members
Points: 273 Visits: 343
Hi,

When calculating the average value, its ignoring the zero values.

For ex: to calculate the average of 10,20,30,0,0 it is calculating as 60/3 instead of 60/5.

Can anyone pls let me know what should be the issue in SSRS

I have given it as
CStr(CDec(Round(Avg(Fields!QUOTE_VAL.Value),2)))

and tried with different conversions in CDec area.

Thanks
Naveen
robert.gerald.taylor
robert.gerald.taylor
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1796 Visits: 1490
Are they really zeros or are they Nulls?

Try adding a check ( IIF() ) to see if the value is Nothing, if so, explicitly make it zero.

Just a thought,
Rob
ekknaveen
ekknaveen
SSC Veteran
SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)

Group: General Forum Members
Points: 273 Visits: 343
I have added iif in both stored procedures as isnull(varname,0)
and also in rdl i used iif isnothing(varname,0,varname) but still no luck

Thanks
Naveen
eric.muller
eric.muller
SSChasing Mays
SSChasing Mays (631 reputation)SSChasing Mays (631 reputation)SSChasing Mays (631 reputation)SSChasing Mays (631 reputation)SSChasing Mays (631 reputation)SSChasing Mays (631 reputation)SSChasing Mays (631 reputation)SSChasing Mays (631 reputation)

Group: General Forum Members
Points: 631 Visits: 1343
Perhaps it's inconsistent type of the data it's operating on?

Try changing it to:

CStr(CDec(Round(Avg(Cdbl(Fields!QUOTE_VAL.Value)),2)))
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