Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Pass Values from One parameter to another

Author  Topic 

Amit-1234
Starting Member

19 Posts

Posted - 2012-09-26 : 05:25:53
Hi,

I have a requirement in SSRS 2008 whenever a user assigns a value to a parameter, the same value will get assigned to another Text parameter.
I have tried that using default values option in the parameter properties box, but in that case only the value which is assigned for the first time is getting assigned. New values are not getting accepted.
Kindly help.

Regards
Amit

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-26 : 07:09:08
That should work - not sure why it is not working for you. Can you try the following exactly as I am describing? I tried this in a test report and it works as you and I are expecting it to.

In parameter properties, under Default Values, click Specify Values and Add. Click the expression button and enter =Parameters!p1.Value for the Expression Value. (p1 is the parameter whose value you want to assign to this parameter). Click Ok and run the report.
Go to Top of Page

Amit-1234
Starting Member

19 Posts

Posted - 2012-09-27 : 03:40:53
Hi,

Thanks for the help. I exactly followed the steps as mentioned and came across an observation.

I went to the preview mode and assigned the datetime parameter. Immediately the value got assigned to the desired parameter and the report got displayed. But now if i change the datetime parameter again and run the report at this time it is not working. So, I again went back to the design tab and reopened the report in preview mode and assigned another value for datetime. This time the new value is getting assigned which means that the initially assigned parmeter values are not getting refreshed or changed during report runtime. In that case the problem is if i deploy the report in web, the user has to either refresh the page manually or close and reopen the browser window everytime he wants to enter values for the second time.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-27 : 07:19:26
Yes, I also see the behavior you described. Do you need the parameter to be visible to the user? If that is not requirement, make the parameter internal or hidden (on the general tab of the Parameter Properties). Then it will pick up the value from the other parameter every time the report is run.

I can sort of see why Microsoft did it this way - i.e., the thinking must have been that when the user has the parameter in front of him/her and is enabled, it assumes that the user has control s/he better change it than the system trying to mess with it.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-27 : 11:09:19
Sorry not sure if i'm missing something.
If you're linking to first parameter from second parameter by specifying it in available values section then it will change value based on what you select for first parameter
I tried creating a sample report with two parameters (param1,param2)
then set second param (param2) avaiable values tab an expression as =Parameters!param1.value

and went to preview and whatever values i picked for param1 it assigned it automatically to param2 without any refreshing

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Amit-1234
Starting Member

19 Posts

Posted - 2012-09-28 : 03:04:50
Actually, I also tried it using available values and it is true that the values are getting refreshed at runtime based on the value the user assigns to the first parameter.

But, there is also another problem. Suppose, I have assigned a date value in the first parameter, the values are immediately getting refreshed in the second parameter. In this case second parameter is also becoming like a drop-down box from where the user has to select the refreshed value. This will become a problem if i want to keep the second parameter as hidden.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-28 : 07:01:14
quote:
Originally posted by Amit-1234

Actually, I also tried it using available values and it is true that the values are getting refreshed at runtime based on the value the user assigns to the first parameter.

But, there is also another problem. Suppose, I have assigned a date value in the first parameter, the values are immediately getting refreshed in the second parameter. In this case second parameter is also becoming like a drop-down box from where the user has to select the refreshed value. This will become a problem if i want to keep the second parameter as hidden.

If you make the parameter internal, it should not prompt the user to set it. In fact, if it is internal, the user has no option or ability to change it directly.
Go to Top of Page

Amit-1234
Starting Member

19 Posts

Posted - 2012-09-28 : 09:01:12
Incase of available values, the first default value is "Select a value" followed by the actual values. So if I make the parameter as hidden or internal and try to run the report it will stop the user and ask the user to fill in the value for the unseen parameter.

Is it possible in any way to directly assign the selected value in the second parameter and stopping it from becoming a combo where the default value by default is "Select a value"?

Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-28 : 09:26:32
quote:
Originally posted by Amit-1234

Incase of available values, the first default value is "Select a value" followed by the actual values. So if I make the parameter as hidden or internal and try to run the report it will stop the user and ask the user to fill in the value for the unseen parameter.

Is it possible in any way to directly assign the selected value in the second parameter and stopping it from becoming a combo where the default value by default is "Select a value"?



Don't give any available values. Just give one default value as I described in my previous post and make the parameter internal. Seems to work correctly in whatever tests I could do.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-28 : 10:38:26
quote:
Originally posted by Amit-1234

Incase of available values, the first default value is "Select a value" followed by the actual values. So if I make the parameter as hidden or internal and try to run the report it will stop the user and ask the user to fill in the value for the unseen parameter.

Is it possible in any way to directly assign the selected value in the second parameter and stopping it from becoming a combo where the default value by default is "Select a value"?




the reason why you set parameter value from other parameter is beacuse you dont want user to set it manually isnt it?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Amit-1234
Starting Member

19 Posts

Posted - 2012-09-29 : 01:48:31
Yes, finally it worked. I used the default value option and set the parameter as internal. Its working fine now.
Thanks to all , for your valuable suggestions.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-01 : 10:54:15
ok...so far as you dont want parameter to be controlled from outside you can use internal type

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -