Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Changing Field Value With Parameter


Changing Field Value With Parameter

Author
Message
mbrady5
mbrady5
SSC-Enthusiastic
SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)

Group: General Forum Members
Points: 129 Visits: 749
Hi,

I'd like to change a field value in my main data source query using a parameter. I cannot figure this out.

I'd like to be able to use a parameter to change the field 'DueDays' to 'AgeDays' and vice versa if I choose. I would specify my parameter values as the coordinating field names which are;

AgeDays
DueDays

Select Last,First,SiteName,DueDays 
From My Table



Seems like such an easy thing to accomplish but apparently not for me. Thanks
davoscollective
davoscollective
SSChasing Mays
SSChasing Mays (601 reputation)SSChasing Mays (601 reputation)SSChasing Mays (601 reputation)SSChasing Mays (601 reputation)SSChasing Mays (601 reputation)SSChasing Mays (601 reputation)SSChasing Mays (601 reputation)SSChasing Mays (601 reputation)

Group: General Forum Members
Points: 601 Visits: 1000
mbrady5 (3/18/2013)
Hi,

I'd like to change a field value in my main data source query using a parameter. I cannot figure this out.

I'd like to be able to use a parameter to change the field 'DueDays' to 'AgeDays' and vice versa if I choose. I would specify my parameter values as the coordinating field names which are;

AgeDays
DueDays

Select Last,First,SiteName,DueDays 
From My Table



Seems like such an easy thing to accomplish but apparently not for me. Thanks


There's a couple of ways you could do this. I would recommend against a dynamic SQL route, which could be accomplished either by using a stored proc (pass a parameter telling the proc which of those fields you want, and then using an IF/ ELSE in the proc to call one query or another) or in an expression by constructing SQL from a string:

="Select Last,First,SiteName, " + @AgeOrDueDays + "
From My Table"



Don't do it that way though.


Better to return both fields to the report and choose which you want in there

Select Last,First,SiteName,DueDays, AgeDays
From My Table



In the tablix, you can use an expression for both the column heading and the cell value.

The @AgeorDueDays parameter can have 2 available values
"AgeDays"
"DueDays"
You could use the same values as the labels.

The expression in the table would be
=IIF(Parameters!@AgeorDueDays.value = "AgeDays", Fields!AgeDays.value, Fields!DueDays.value)

And the heading expression:
=IIF(Parameters!@AgeorDueDays.value = "AgeDays", "AgeDays", "DueDays")
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search