Sorting a CrossTab Report Crystal Reports - sorting

Recently I had a problem with sorting a crosstab. I finally found a way to display the results as expected so I thought my solution may eventually help somebody else.
The "original order" doesn't work within Crystal Reports crosstabs unfortunately. The original "order by" section of my sql query contained two column: first a nvarchar column then a int column. In my results I only needed to display a concatenation of those two columns so the results normally looked like this with sql : A1, A2, A3, A10, A11.
But when it came to display the results in a Crystal Report crosstab, the sorting was different because crosstab's sorting is based on the columns/rows displayed only, not the "original order by" from the query results, so the results showed with the crosstab was instead: A1, A10, A11, A2, A3.
My way to solve this issue was to add those 2 fields within the rows section before my "concat field" because they were required for the sorting and to display only my "concat field". To hide fields within a crosstab, just go to this tab: "Customize Style Tab" (from the Cross-Tab Expert). Then select the field to hide within the Rows section and click "Suppress Subtotal" and then "Suppress Label". And it worked like a charm. Hopefully it will helps you guys saving time.

But This solution have some limitations like
if you want to export the report in Excel then it will add extra cells in grand total.
otherwise it is a good to go.
Example:
If you have 3 rows(A,B,C) to display and you added one row and you suppress it to solve your sorting issue then in Excel its grand total looks like
A B C
a 1 3
b 2 2
---------------------------
Total: 3 5

Related

How to disable CrossTab sort order?

I have a crossTab in my report that shows:
L S XL Changes Combination Material
Shirt 10 5 something somethiung something
Pants 2 4 something somethiung something
But I need it to be sorted like this:
Material Combination Changes S L XL
Shirt something somethiung something 10 5
Pants something somethiung something 2 4
Now keep in mind that I already sort the values the way I want them to be sorted in my stored procedure the only problem is that CorssTab has its own sorting and so far I haven't found a way to disable it.
I am using Visual Studio 2013 and Crystal Reports 13.0.10 and SQL 2014 (tho i doubt SQL version matters).
I am not allowed to change the version of VS or CR or SQL that I am using.
If needed I can provide you with everything you need in order to 'test' my question if you don't believe that my stored procedure sorts the values in one way but CrossTab ignores it.
Please check this link or this
This option is available in Cross-tab popup, below the column selection there is "Group option".
Create a Select Case formula that adds the desired sort position as a number before each group value:
Material
Combination
...
Use that formula for the CrossTab column
Then, use the CrossTab Group Options dialog, Options tab, to 'Customize Group Name Field' with the option to 'Use a formula as Group Name'.
In that expression, return MID({#ColumnFormula}, 4) to throw away the number prefix.

How To Sort Specific Column Data in SSRS Tablix

I am using Visual Studio 2012 for SSRS and my queries come from using Microsoft SQL Server 2012.
My question below pertains to SSRS and sorting.
In my Tablix, I currently have the Row Groups set up as Group -> Manager -> Owner -> Status Description and when it pulls the data from the data from the dataset, it pulls in fine. In the tablix, basically everything is a drilldown and each of the Row Groups (except Group) is hidden initially and can be displayed/toggled by the report item ahead of it. In the Status Description part, when it pulls in the records, it pulls them in as Active, Completed, In Process...which is fine because they are pulling in ABC Order.
But I want to show that specific column when it pulls in as Active, In Process, Completed...in the way that a specific file would go through the process. These are only 3 specific ways the data could pull it as, there are more, but these are the most common seen. How do I sort that individual column to get it in the way I mentioned above or a way that I can customize the sorting based on how I want it to be seen?
You can use expressions in the sort order to get the sorting exactly as you'd like.
What you can do is use the SWITCH statement to number your output in the order you want. For example I have 3 statuses: "Complete", "On Hold" and "Word at Risk". Normally they would either sort as Ascending or Descending... but if I enter this in the Sort Order Formula I can change that:
=SWITCH(
Fields!PRS_STATUS.Value = "Complete", 1,
Fields!PRS_STATUS.Value = "Word at Risk", 2 ,
Fields!PRS_STATUS.Value = "On Hold", 3)
And now it orders 1,2,3 aka Complete, Work at Risk, On Hold.
You can put this switch in a larger switch statement to have multiple sort orders depending on a criteria or parameter.

Crystal Report Groups Duplicate My Values

I'm trying create two groups from two different tables. I choose create new crystal report (As A blank report) then i create two groups like following images:
Then I'm choosing the table. I'm doing this once again with another table i want.
My Crystal report design look like this:
Now my Result is this:
But I want to take this result:(This result is painted)
Maybe it looks like easy for you, but i need a helping hand for solving this.
I choosed link options(Full inner join)
In Design Form
The grouping functionality within Crystal maintains the data relationship and makes it easier to read by not repeating the group text for each line item - if you group by "A", you will see all items, including the "group 2 duplicates" so long as they are in group A. Adding a second group will further refine the subset of results.
This is the intended and expected behavior for Crystal - SQL-level grouping is different and is used for aggregate functions, among other things.
If you are trying to create a multi-column report, look at this
Can I make a two column Crystal Report? - Under Section Expert, go to Details and click the box "format with Multiple Columns", then click Layout at the top and enter the detail size, in inches, as well as the gap between details. if you want your groups to continue in the additional columns, click the "Format groups with Multiple Column" checkbox.
If this does not satisfy your requirement, you may have to reevaluate the report requirements and the dataset limitations.

How can I get the values in the Matrix on my SSRS report to repeat?

I know there must be a simple answer to this, but I can't find it.
I have added a couple of textboxes to a Matrix in a BIDS/SSRS report. I've given these textboxes values such as:
=Fields!WEEK1USAGE.Value
It works (after a fashion); when I run the report (either on the Preview tab, or on the Report Server site) I see the first corresponding data value on the report - but only one.
I would think that once a value has been assigned via expressions such as "=Fields!WEEK1USAGE.Value", each value would display (rows would automatically be added).
There must be some property on the Matrix or the textbox that specified this, but I can't see what it might be.
Here is how my report looks (very minimalistic, so far) in the Layout pane:
...and after running, on the Preview tab:
Obviously, I want the report to display as many rows as necessary, not just one. The textboxes do have a "RepeatWith" property, but there description doesn't sound interesting/useful/promising.
I don't see any property on the Matrix control that looks right, either.
I thought maybe the designer was only showing one row of values, and ran the report on the server, too, but there also it just shows the two values.
So what do I need to do to get all the data for a provided field?
Matrices are for display of grouped data and summary information, usually in a horizontally expanding pivot table type of format. Is a matrix really what you are after? Looking at your expression you have =Fields!Week1Usage.Value but in a matrix what I expect to see would be at least =Sum(Fields!Week1Usage.Value) or even better just =Sum(Fields!Usage.Value). Then you would have ProactDescription as your row group and the week as your column group and it would all just work out everything for you, grouping and summing by Proact vertically and expanding the weeks out horizontally.
What seems to be happening is that you have no grouping on rows or columns and no aggregation so it is falling back to the default display which is effectively the First function - it displays the first row of data and as far as the matrix is concerned it has done its job because there is no grouping.
Without knowing your problem or data, I'll make up a scenario that might be what you are doing and discuss how the matrix does the heavy lifting to solve that problem. Let's say you have usage data for multiple Proacts. Each time one is used you record the usage amount and the date and time it is used. It could be used multiple times per day but certainly multiple times in a week. So you might be able to get the times each Proact is used from a table like so:
SELECT ProactDescription, TimeUsed, Usage
FROM ProactUsage
ORDER BY ProactDescription, TimeUsed
In your report you want to show the total weekly usage for each Proact over multiple weeks. Something like this:
Proact Week1 Week2 Week3 ...
Description Usage Usage Usage ...
--------------------------------------------
Anise, Fennel 1 CT 20.00 22.50 16.35 ...
St John's Wort 15.20 33.90 28.25 ...
...
and so on. Using a dataset based on the SQL above we create a matrix and in the row group properties we group on =Fields!ProactDescription.Value and in the column group properties we group on a week expression like =DateDiff(DateInterval.Week, Fields!TimeUsed.Value, Today) and then in the intersection of the row and column we put =Sum(Fields!Usage.Value). To display the header of the column nicely put an expression like
="Week " & DateDiff(DateInterval.Week, Fields!TimeUsed.Value, Today)
The matrix automatically does all the summing by week and product and expands the weeks horizontally for as many as you are reporting. For bonus points you can also put totaling at the end of the columns and the rows to show the total use of that Proact for the period (row total) and total use of all Proacts in that week (column total).

SSRS 2008 Interactive Sorting in Sub-Report not working as expected

I have a (parent) report that has a list. The details group of this list contains one sub-report. So basically if the list has 10 records (rows) the sub-report is executed 10 times.
The problem seems to be with interactive sorting in the Sub-Report. It has 4 columns with interactive sorting enabled. When I run the parent report and try to sort columns SSRS "remembers" the previous sort column and sorts by multiple columns at the same time. For example if I sort by Col A then click to sort by Col B, SSRS will preserve the sorting of Col A (and the direction) and then apply the sorting to Col B. However I simply want to sort by Col B and do not want to Col A to be part of the sort.
When I try this directly with the sub-report everything works as expected.
Any ideas why this is happening?
This is a potential bug in SSRS 2008. I used a table instead of a list in the parent report and everything is now working correctly. Go figure!

Resources