Friends,
I am using Tablix Control in RDLC to generate matrix report. In the last column of my matrix (group) report I have defined a formula using expression Now my user want to sort this column by ascending or descending.
(Criteria will be sent to report via Report Parameter).
I found sorting under Row Group - > Group Properties -> Sorting.....
But I am not sure how to do sorting on column which is calculated based on formula.
How can I do that? Can any one tell?
New answer:
If you do not need to use a parameter for triggering this sorting, then Interactive Sorting would accomplish exactly what you are looking for. Right click on the header of the column in question and you should see Interactive Sorting.
If it needs to be a parameter for whatever reason, then it would depend on the data type. If it is some kind of numeric type, then you could have the parameter value be either 1 (ascending) or -1 (descending). You would then sort on the parameter multiplied by the expression for that column.
Related
I am designing a report for SSRS. I want the user requesting the report to be able to specify, when they generate the report, from a pre-defined selection some values which should be displayed in a tablix on the report.
I have therefore created a multi-value parameter and populated the Available Values with the options I want the user to be able to select from, and, as expected, when the report is generated the user is able to select one or more of these values.
However, what I now want to do is include a tablix in the report, and display a row for every value in the multi-value parameter that the user selected, with the value displayed in the first cell of the row.
If the values were coming from a data table this would obviously be easy. I've also found answers on how to show all of the selected parameter values in a single textbox using the JOIN function, but I don't want to do that.
The only solution I can think of is to replicate the list of available values in the multi-value parameter in a tablix manually, and link the visibility of each row of the tablix to the selected state of the corresponding value in the multi-value parameter, but that's not very elegant and increases the effort involved in maintaining the report definition.
Any ideas on how to do this? I know the selected values from the parameter simply form an array, but I can't see how to bind a tablix to any data that isn't in a dataset, or how to create a dataset from the parameter values.
Considering that a tablix sources from a dataset, I did some experiments to see how to create a low maintenance solution for you.
Option 1: Create a data set with hard-coded options to match your multi-value parameter and select those options WHERE they exist in the parameter.
Example:
SELECT val
FROM (
SELECT 'opt1' as val
UNION SELECT 'opt2'
UNION SELECT 'opt3'
UNION SELECT 'opt4') a
WHERE val IN (#Param)
Thoughts: easier to maintain than visibility on a table, but still two hard-coded places within the report.
Option 2: Create a dataset that selects the multi-value parameter and splits it by each value. This was my first idea, but I ran into some issues with determining how to actually select the multi-value without a syntax error. I came up with a method that creates a deliminated string in the report and than parsed that string back into rows in the dataset:
Step 1) Within the dataset properties, on the parameter tab, join the multiple values together with a JOIN expression
Step 2) Create a simple query which uses the new SQL Server 2016 function string_split. Note that your database compatibility level MUST be 130 or higher to use this function (SQL 2016+). If this isn't your scenario, there are many string split functions that you can find on Stack Overflow to achieve the same thing.
Fun problem!
I am generating a table in SSRS based on the selection made by the user on two filters: Filter1 and Filter2 (say). The table so displayed has 10 columns and I wish to add filter option listing all available values for that column for all 10 columns.
Basically, I am trying to replicate the Excel functionality of filtering down data on each and every column.
Please note that I tried creating a new data set and a parameter taking all distinct values for a particular variable. However, I am still not able to get the desired results by filter the tablix on that parameter
Is there a way I can do that?
You'd need to make a new dataset that is a smaller version of your main dataset. It would need to return all potential values for the column(s) you want to filter in a single column to be used in a parameter.
Without seeing the design of the report or the dataset itself it's quite hard to be more specific.
REPORT BUILDER 3.0
I am changing the data sets of our reports to standard data sets. In some cases the names of fields have changed. Despite changing the cells to the new names I get an error of:
"The Group expression for the grouping ‘companyname’ refers to the field ‘companyname’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case.
"companyname" changed to CompanyName and there is no group by companyname in the Dataset SQL. How can I change that in SSRS?
Whenever I've faced this, the places to check are:
Row Groups
Column Groups
Header text boxes for interactive sorting
9 times out of 10 when I can't find it, it's in the interactive sorting on text boxes.
Is it possible to write a query as an expression in a textbox in rdlc? I am trying to show row position of a field after ordering them in descending order.
If not possible, how can I achieve this apart from passing the values via parameters?
Hi I am new to SSRS and I created a form. I also added a couple of column based on expressions. I was trying to sort the table on the basis of an expression column but the option is not available in cell properties - interactive sorting. Can anyone please guide me on how to achieve it. Thanks.
You have two ways of solving this that I can think of. You can either:
Move your calculated columns to your Dataset
When you add a dataset to a report, on the Fields tab you have the option to add Calculated Fields. If you add your expression column here, you will be able to use it in the Sort tab of your Tablix just as you would a normal column.
OR
Repeat the expression in the Sort property.
If you are not able to create your calculated field on your dataset (perhaps if you reference other datasets or do something out of scope), then you will need to duplicate your expression in the Sort tab of your Tablix. (To access this, click anywhere on your table and then right-click on the small grey square in the top left-hand corner of your table).
If you click Add for a new Sort condition and hit the fx button, you can paste the same expression you used for your column into here and use it to sort your dataset.
The downside of this is that you're replicating your logic and potentially duplicating work.
To enable the interactive shorting in a table you need to have a row group. So by this you can sort the whole table or only a portion of the table.
Say in your case you need to sort the table basis of some expression. For an example you need have an interactive sort based on the values. In the below screenshot I have 2 groups i.e. Customer and Project and I want to have an interactive sort based on the revenue.
Now right click on the Revenue and go to the 'Textbox' properties and select the group and sort by. Here in the screenshot I will sorting based on the total revenue for different Customers.
Now after running the report if you click on the Revenue column it will sort accordingly.
Let me know if this is what you are looking for.