Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 576
Aylin Avatar asked Apr 17 '17 14:04

Aylin


2 Answers

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)
like image 102
Pops Avatar answered Oct 01 '22 12:10

Pops


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

like image 22
Rickey Alterman Avatar answered Oct 01 '22 14:10

Rickey Alterman