none
sorting on an expression RRS feed

  • Question

  • I wanted to create a column which was one field divided by another field, and then sort on it.


    I started with

    Fields!FG.Value)/Fields!ADU.Value

    but of course when ADU was 0 it caused an error. then I went to


    =iif( Fields!ADU.Value =0,0,(Fields!FG.Value)/Fields!ADU.value)


    but sadily it evaluates both the true and the false return values before figuring out which one it would need to return. So then I used this.


    =iif( Fields!ADU.Value =0,0,Fields!FG.Value/ iif(Fields!ADU.Value=0,1,Fields!ADU.value))


    Which actually works and returns what I would expect it to. Then I go into the report properties and say that I wish to sort on an expression, and enter the above expression. It fails with the following error


    "An error has occurred during report processing.

    The processing of sort expression for the table 'table1' cannot be performed. The comparison failed. Please check the data type returned by sort expression."


    Does anyone have any ideas?

    Friday, June 17, 2005 5:59 PM

Answers

  • Use the following expression instead:

    =iif( Fields!ADU.Value = 0, 0.0, CDbl(Fields!FG.Value/ iif(Fields!ADU.Value=0, 1, Fields!ADU.value)))

    -- Robert
    Saturday, June 18, 2005 1:06 AM