Getting NaN value

  • 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

  • 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.

  • 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