November 15, 2017 at 11:27 pm
i'm getting the error: An expression on non-Boolean type specified in a context where a condition is expected.
I have a report with multiple matrix with different RowGrouping. e.g matrix 1 is grouped on staff member, matrix 1 grouped on StockItems. the matrix are displayed based on parameter = @Dimension and it's a multiple select so the visibility expression is: =InStr(Join(Parameters!Dimension.Value,","),1)<=0
in the sql query I used two separate if's. the first IF statement get's data for the StockDescription matrix and the second If pulls data for the other matrix.
IF @Dimension = 2
then 'SELECT * from Table1'
end
IF @Dimension <> 2
begin
'SELECT * from Table2
END
i'm getting error when selecting multiple @Dimension when I run the report.
November 22, 2017 at 3:23 pm
I may be mistaken on this, but I think that the problem is that @Dimension is not containing a single int value. You say that it is multiple selects. So I am expecting that @Dimension is going to return an array like structure.
So as soon as more than 1 value is selected, you end up with @Dimension being something like (1, 2, 3). So when you have "IF @Dimension = 2", you are saying "IF (1, 2, 3) = 2".
If you are wanting to check if @Dimension contains 2, you would likely get better results by using "IF 2 IN (@Dimension)". If you are wanting to know if @Dimension equals 2, you will likely want to store the value into a separate string variable and do your comparison that way. Depending on how many selections you ahve in @Dimension, you may want to turn the selection list into a comma separated list and store that for doing the comparison (using =JOIN).
Now, I could be misunderstanding what you are asking, but I think the problem is due to @Dimension containing multiple values and that it works as expected with a single value for @Dimension. Ist that correct?
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply