This is a migrated thread and some comments may be shown as answers.

Parameter for column name

1 Answer 237 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ctrax
Top achievements
Rank 1
Ctrax asked on 27 Jun 2012, 04:44 PM
I am wondering if it is possible to build a report that contains 1 parameter where the user can select a column name, and 1 parameter where they enter a value.  Below is an example of a report query that would be used in this scenario:

select Name, City, State
from Customers
where @field = @value

Then if the following is selected for the parameters...

@field = City
@value = Boston

the report would return all customers where City = 'Boston'.  I understand that I can create separate parameters for each individual field, but in my actual scenario I am dealing with a much larger number of fields (20+), and am looking for a simpler solution where they can just select a column name from a dropdown.

So is it possible to use this type of parameter in a Telerik report?


1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 28 Jun 2012, 02:40 PM
Hi,

You can accomplish your requirement with report filter. You can use the Fields(fieldName) expression function in report filter. Where fieldName is the parameter value. Check out the following example:

Expression  Operator Value
 = Fields(Parameters.Parameter1.Value)
 =  =Parameters.Parameter2.Value 

Another approach is to utilize a stored procedure as elaborated in How to use TSQL parameters to actually use it as an Identifier rather than the value? MSDN blog.

Greetings,
Peter
the Telerik team

FREE WEBINAR ON THE NEW REPORT DESIGNER! Join us on Friday, June 29 at 10:00 AM PST for a comprehensive demo of the official version of the standalone Report Designer and find out how easy it is to empower your users with creating, editing and sharing ad-hoc reports. You may even win a free Telerik Ultimate Collection license! Register today >>

Tags
General Discussions
Asked by
Ctrax
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or