June 6, 2008 at 11:06 am
I'm calculating Average Ticket Order for a group:
=sum( Fields!TtlSales.Value) /
sum( Fields!TtlOrders.Value)
But I noticed that when Sales and Orders are 0 then NaN value displays.
Has anyone got this value before? if so, how do I counter for it?
thx,
John
June 6, 2008 at 1:31 pm
NaN means not a number so I would assume you have null values. You also need to be careful that your divisor is not 0 or you will get a divide by zero error. I would probably convert my nulls to 0's and check for 0 in the divisor. Something like this:
=IIF(Sum(IIF(Fields!TtlOrders.Value is nothing, 0, Fields!TtlOrders.Value))<>0,
Sum(IIF(Fields!TtlSales.Value is nothing, 0, Fields!TtlSales.Value))/
Sum(IIF(Fields!TtlOrders.Value is nothing, 0, Fields!TtlOrders.Value))
That code may not be perfect, but it should give you a starting point. You could do the conversion to 0 from Null in your T-SQL or by creating a calculated column in the dataset.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
June 10, 2008 at 9:12 am
Thanks a lot Jack, that was very helpful.
John
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply