Syntax error

  • =iif(Parameters!PUBLICATION.value = 304 or Parameters!PUBLICATION.value = 305, round(Fields!LASTWEEK.Value/5), round(Fields!LASTWEEK.Value))

    Please check the syntax it gives me "#Error" always. Thanks.

  • what is the data type set for the parameter? if it is string as in default then that would trigger the error in the expression.

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

  • Data type is set to integer, but i still get the error. Please help me with this.

  • I am not entirley sure you can use an or in an IIF in that way. try removind the second clause and see if that takes care of the error. if it does then you can change the expression to a SWITCH.

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

  • I'm sure dan is right...you can only test for a single value in the IIF condition, so you need nested IIf's to do the OR:

    =iif(Parameters!PUBLICATION.value = 304,round(Fields!LASTWEEK.Value/5),IIF(Parameters!PUBLICATION.value = 305,round(Fields!LASTWEEK.Value/5),round(Fields!LASTWEEK.Value)

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks for replying again.

    I tried

    "=iif(Parameters!PUBLICATION.Value = 304,"red","orange")" with PUBLICATION as integer but still it gives me the same error.

    and also "=switch(Parameters!PUBLICATION.Value = 304,"red")"

    I got error for both.

  • In the parameters i did allow multiple values. If unselect that report works fine. Can we write the expression in such a way that it accepts multiple values.

  • when you allow multiple values the values are stored and passed as a string pretty much no matter what you do. If you select 1,2,3 while each value may be a valid number the combined "1,2,3" is in fact a string so the string is pased in to the wuery where it is used in a where cluse with IN or some such clause. So where does that leave you well my gut reaction is to do something similiar to a LIKE in the expression but I have tried to find an example of that and I have consulted the pragmaticworks cheat sheet which If you have not seen is worthing looking at but I can not figure out the equivaliant of a TSQL Like. That is what would be required though since the parameter value would be equal to something like "1,2,3" rather than a single integer value.

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

  • Sorry...this entry looks redundant with one above.

    You might also try this

    =iif(Parameters!PUBLICATION.value = 304, round(Fields!LASTWEEK.Value/5), IIF(Parameters!PUBLICATION.value = 305,round(Fields!LASTWEEK.Value/5),round(Fields!LASTWEEK.Value)))

  • First, you can use OR in an IIf statement with no problem. I have done this several times, and used AND also with no issues.

    Now, on to the issue - which is the fact that you are using multi-value parameters which is causing the problem. What column are you checking in your query against that parameter? Could you use that column from the resultset instead of checking against the parameter?

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply