Showing posts with label direction. Show all posts
Showing posts with label direction. Show all posts

Friday, March 9, 2012

Dynamically change sort direction

Hello all! I have a report to be rendered in PDF format. On the report is a
list. I'm trying to dynamically change the sort direction of my list sorting
at run time, depending upon what parameter value is passed into the report
i.e. ascending or descending. Is this possible? I've tried editing my rdl
code numerous ways along these lines but it throws up an error no matter what:
<SortBy>
<SortExpression>Fields!sortby2.Value</SortExpression>
<Direction>=iif(Parameters!sortdir.Value = "Asc", Ascending,
Descending)</Direction>
</SortBy>
Any guidance would be greatly appreciated - either in doing it this way or
some other.
Thanks,
DaveDave,
I used this and it worked for me. I use two parameters, one telling
direction, one telling what column to sort by.
=iif(Parameters!Direction.Value="Ascending" AND
Parameters!SortBy.Value="quantity",Fields!quantity.Value, 0)
Put this in one column, and select Ascending in the other column.
"Dave" <Dave@.discussions.microsoft.com> wrote in message
news:Dave@.discussions.microsoft.com:
> Hello all! I have a report to be rendered in PDF format. On the report is
> a
> list. I'm trying to dynamically change the sort direction of my list
> sorting
> at run time, depending upon what parameter value is passed into the report
> i.e. ascending or descending. Is this possible? I've tried editing my rdl
> code numerous ways along these lines but it throws up an error no matter
> what:
> <SortBy>
> <SortExpression>Fields!sortby2.Value</SortExpression>
> <Direction>=iif(Parameters!sortdir.Value = "Asc", Ascending,
> Descending)</Direction>
> </SortBy>
> Any guidance would be greatly appreciated - either in doing it this way or
> some other.
> Thanks,
> Dave

Wednesday, March 7, 2012

dynamic where clause

Hi

I need some advice on which direction to take!

Consider this statement:

SELECT business_name FROM myTable WHERE town = @.town AND county = @.county

My problem is that i will not always have the @.county variable available. Is there a way to use an IF or a CASE inside the SQL statement (i know i can create two seperate sql statments but dont want to do it this way)? If it makes it easier, when the @.county variable is not available, it has a value of 0.

thanks again

Ps, i also know how to do it using dynamic sql using the EXEC() command, but i'd prefer to steer clear of this method also.SELECT business_name
FROM myTable
WHERE (town = @.town OR @.town IS NULL)
AND (county = @.county OR @.county = 0)
?|||Hi pootle

If the @.county has a value of 0 then i don't want to make it part of the WHERE clause, ie i dont want it to search the county column - in your example it would search all counties which are equal to 0?

This is what i'm trying to acheive, but only use one SELECT statment:

IF @.county <> '0'
BEGIN
SELECT business_name FROM myTable WHERE town = @.town AND county = @.county
END
ELSE
BEGIN
SELECT business_name FROM myTable WHERE town = @.town
END|||Hi Mattock

Did you try the code? I know the answer is no :) It does just what you ask for.|||lol, i'm real sorry, got the monday morning blues! Thick mode was well and truly stuck to 'ON'.

cheers again|||No probs :)