Aylin
Aylin

Reputation: 177

how to sort table by parameter on SSRS

I have a report on SSRS. I have order and Planned Start column on table. I want to add now the option to order by line or by Planned start time.

I mean if I choose line, our report must be sort for line if I choose planned start time, report must be sort for planned start time

How should I do like this? Could you help me please?

enter image description here

Upvotes: 6

Views: 5071

Answers (2)

Rickey Alterman
Rickey Alterman

Reputation: 11

You can add a variable to the SQL script @param then pass it from the parameter just like passing any other parameter. SELECT * FROM table ORDER BY @param

Upvotes: 1

Pops
Pops

Reputation: 498

You can create a report parameter called something like "Order By", and make the available values as Line and Planned Start Date. Then, lets say you have a simple report with just one Details group, go into the Group Properties and in the Sort tab, set the sort expression as something like:

=iif(Parameters!OrderBy.Value = "Line",Fields!LineNumber.Value,Fields!PlannedStartDate.Value)

Upvotes: 1

Related Questions