SSRS Matrix Grouping Vertically to keep headers in same column? Is it not possible? - ssrs-2008

using SSRS 2008 R2 here.
I've been able to get a similar layout to work with a regular tablix, where I get each group header to fall on top of each other in the same column by adding a row within that group, however I need to use a Matrix because of a dynamic column (month below). When I try to add another row, it only adds a row where the monthly data starts, not in the headers. So the headers stay in their each column. In trying to keep the example as easy as possible, I'm trying to do something like this (Store theme).
STORE NAME | MONTHS
STATE | SALES
TOWN(S) | SALES
which woudl look something like this in a Matrix
WALMART JAN FEB MARCH etc....
TEXAS | 3000 2000 6000
HOUSTON | 1000 500 2500
AUSTIN | 2000 1500 3500
I've only been able to produce something like this where each group is a seperate column:
STORE | STATE | CITY | JAN | FEB | MAR |
WALMART | TEXAS | HOUSTON | 1000 | 500 | 2500 |
| AUSTIN | 2000 | 1500 | 3500 |
Again, I've been able to get a regular Tablix formatted like this, but a Matrix I'm struggling with. Can anyone help me on how to do this? Thank you in advance!!

It is possible using a tablix/matrix and adding some special grouping settings.
Add a tablix with the City field in Row Groups pane:
Right click the City group, select Add Group / Parent Group. Choose State and set Add a Group Header
Delete the left most column (State column added in the previous step).
Note the group is still present.
Right click the STATE group and add a Parent Group as step 2. In this case choose STORENAME
Again delete the left most column (Store Name column added in the previous step)
You will get the following tablix.
Delete the first row
Set the Fields using the Row Group hierarchy order. STORENAME/STATE/CITY
Right click the first cell in the next column and add a group / Column Group / Parent Group. Choose MONTH in group by.
Delete the first row.
Set SUM(Fields!Sales.Value) in the next cells in the same column.
After these steps you will get a tablix like this in design window.
It should produce:
Let me know if this helps.

Related

How To Aggregate Up From A Text Table With Calculated Fields?

With tableau I am able to act on some data tables to get to a text table that I would like to treat as a table from scratch to do further aggregation. You will see from my example what I actually want to do, but acting on a text table as if it were a brand new table seems to be one solution if possible. I am open to other solutions to the same problem if you have any.
Say I have two tables.
Table A
Date | Purchases
'2014-05-02' | 5
'2014-05-03' | 6
Table B
Date Bucket | Bake Rate
0-1 Month | .20
2-3 Month | .50
First I created a calculated field for Table A to put each line item date into the corresponding date bucket by figuring out how much time has passed from a certain date and called it Date Bucket. Then I made a relationship between Date Bucket in Table B and the newly formed dimension in Table A also called Date Bucket. From Here I could essentially join on date bucket and for each line item get a Bake Rate from table B.
Then I divide each purchase by the corresponding bake rate as determined by how Age Bucket.
So I ended up with a text table like the following.
Date | Age Bucket | Purchases | Baked Purchases
'2014-05-02' | 0-1 Month | 5 | 25
'2014-05-03' | 0-1 Month | 6 | 30
Ideally, from here I'd like to be able to get the sum of the baked purchases and aggregate by whatever other dimensions I have. For example here, get the sum of baked purchases by month.
Any Ideas?!

Crystal Reports report formatting across different pages

I have a question about Crystal Report. I have an existing report, with its data taken from a stored procedure. The data may look like this:
Division|Group Level 1|Group Level 2 |Group Level 3|Value
--------+-------------+-------------------+-------------+--------
IT |Assets |Current Asset |Cash |100
CORP |Assets |Current Asset |Cash |200
IT |Assets |Current Asset |Receivables |300
CORP |Assets |Current Asset |Receivables |400
IT |Assets |Fixed Asset |Land |500
CORP |Assets |Fixed Asset |Land |600
IT |Liabilities |Current Liabilities|Wages |100
CORP |Liabilities |Current Liabilities|Wages |200
IT |Liabilities |Current Liabilities|Taxes |100
CORP |Liabilities |Current Liabilities|Taxes |100
IT |Liabilities |Long-Term |Bonds |300
CORP |Liabilities |Long-Term |Bonds |400
The actual data may have many more divisions (not just two). In the new report, I want the report to look like the following:
| IT | CORP
Current Asset
Cash | 100 | 200
Receivables | 300 | 400
Total Current Asset | 400 | 600
Fixed Asset
Land | 500 | 600
Total Fixed Asset | 500 | 600
Total Assets | 900 | 1200
Current Liabilities
Wages | 100 | 200
Taxes | 100 | 100
Total Current Liabilities | 200 | 300
Long-Term
Bonds | 300 | 400
Total Long-Term | 300 | 400
Total Liabilities | 500 | 700
So, the report will be expanded to the right, according to the number of divisions. Assume that one page can hold up to 10 divisions. Then if there 15 divisions, then the first page will show division 1 to 10, the second page will show 11 to 15. The items shown on the first and second page will be the same, just for different divisions. The number of divisions are flexible. And also the items are quite a lot (there can be a lot of current assets, liabilities, etc).
For now, I tried to do some formatting in the stored procedure, so the returned data will be like:
Page No | Group Level 1 | Group Level 2 | Group Level 3 | Div 1 | Value 1 | Div 2 | Value 2
--------+---------------+---------------+---------------+-------+---------+-------+--------
1 | Assets | Current Asset | Cash | IT | 100 | CORP | 200
1 | Assets | Current Asset | Receivables | IT | 300 | CORP | 400
and so on.
For division 11 to 15, I set the page no to be 2. And then in the Crystal Report, I will group by : Page No, Group Level 1, Group Level 2, and Group Level 3.
So the Crystal report will show everything on a page based on the page number.
The problem is that:
- If there are a lot of items, then it may not fit in one page as well. For example, assume one page it can fit up to 30 lines, then if I have 40 lines, the 10 lines will be shown in the second page.
But I want the second page to still show the first 30 items for division 11-15, and the third page will show the last 10 lines for division 1-10, and the fourth page will show the last 10 lines for division 11-15.
- The running total in Crystal Report will be reset on each change of the group. Let say I have 40 assets. Then after the 40 assets, which is on the third and the fourth page, it should show the total of the assets. How do I calculate the running total so that it shows up correctly? (Considering I can not just sum it up directly, as third and fourth page should show the total of different divisions).
Is there any solution for this problem or a better approach to format the data?
Thanks.
What is your exact issue?
Formatting the report or calculating running total?
Implement below process
Create a group with "Grouplevle1", Don't supress Group1 Header
Create a group with "Grouplevel2", Don't supress Group2 Header. Create two text filds and write "IT" and "Corp" and place on report
Create a group with "Grouplevel3", Now supress the group3 header
Write a formula and add below code
If Divison="IT"
Then Value
Else o
wirte another formula and add below code
IF Divison="Corp"
Then value
Else 0
Place both forumula in detail and add summary to all sections.Also supress detail section
For all group footers write required text
This will solve your problem.
I would recommend using a cross-tab.
Settings:
Columns: Division
Rows: Group Level 1, Group Level 2, Group Level 3
Summarized Fields: Value
You'll have to experiment with the row-grouping fields to get the correct spacing. Do the same for the column's sizing.
In general, this is how I finally solve the problem:
1. Define how many divisions (NumColumn) to be displayed in a single page.
2. Create a table to store the mapping of the division. The table has column that stores PageOffset and ColumnNo. PageOffset stores the number of page to be added when displaying a particular division. For example, if there are 15 divisions, and a page can only accommodate 10 divisions, then the first 10 divisions will have `PageOffset = 0` and the last 5 divisions will have `PageOffset = 1`. The ColumnNo is the position of a division in the report column. So first division will have value of 1, second division will have value of 2 and so on. 11th division will have the value of 1, etc.
3. Create a result table. For each column in the report, we have 2 database field, value and total.
4. Loop for each record, sorted by the group.
Select the position of the division from the table in step 2. If `ColumnNo = 1` insert a row in the result table. E.g. for division 1 and 11 it will create rows in result table.
After that update the row data, based on the position of the division. So for division 1-10 will update the row created by division 1, division 11-15 will update row created by division 11.
5. Count the number of items in each group and store it into a table.
6. Define how many rows (RowsInPage) to be displayed in a single page.
7. Set PageAdd = 0 and RowsLeft = RowsInPage
8. Loop for each group
Retrieve the number of rows needed for this group
Add the page number of each row with PageAdd
Decrement RowsLeft
If RowsLeft = 0
Increment PageAdd
Set RowsLeft = RowsInPage
End If
9. Loop for each group
Loop from 1 to NumColumn
Update the total field for each division. This total field value will be put in the report as the running group total for that particular division.

Cross tab summary fields don't restrict by column

so I'm working with Crystal Reports 10 and was looking at the cross tab to try and have a nice and neat table of my information. I'm trying to make a report where for each item (as a row), the columns will be the different sizes it comes in and the value of that cell will be the quantity.
So something that looks like this:
Small | Medium | Large
Item 1 1 | 5 | 10
Item 2 5 | 10 | 15
Using the cross tab though, the quantity field I have has to be totalled, averaged, etc. so I can't get the specific breakdown for each size in a nice table like that. Is there any way to tweak the Cross Tab to do this or is there another tool in Crystal Reports that would let me have the quantities per size in that organized fashion?
Thanks for any help you guys can give.
Update:
The cross tab I have tried gives me something that looks like this
Small | Medium | Large
Item 1 16 | 16 | 16
Item 2 30 | 30 | 30
If I put the values in the details section as separate fields, I'm able to get the values to match up properly, but its not the right format. It comes out like this
Item 1 | Small | 1
Item 1 | Medium| 5
Item 1 | Large | 10
Create a Cross-tab
Add {table.size} to the Columns
Add {table.item} to the Rows
Add {table.quantity} to Summarized Fields

SSRS - show row total in column

I am working on SSRS 2008.
I have a report as follows, I want the toal of Amount in Total column. I am not able to get total in column. I have tried Add Total / Sum() features of SSRS but no luck.
+---------+-------+--------+-------+
|Supplier | Agent | Amount | Total |
+---------+-------+--------+-------+
| | A10051| 237.2 | |
|S2005068 +-------+--------+ |
| |A10052 | 23.8 | |
+---------+-------+--------+-------+
I think your design is not proper. The total row in the last column will be under the details group. If you want a total on the last column you can get but for-each row it will repeat. use
=Sum(Fields!Amount.Value,"Supplier") here Supplier is the "Group Name"
To avoid this repeatition we need to add the total column inside the supplier group and use =Sum(Fields!Amount.Value) for total
or
Right click on the Amount column data -> Add Total -> Before or After. This will display the sub-total for the Supplier group in the same Amount column after/before as you selected.
Add total on the supplier group, add it before or after, depending if you want it on top or bottom. SSRS will fill in =SUM(Fields!Amount.Value) and show the total 268 below.
To make a Total Rows =countRows("dataset")

Summarizing by group and subgroup

I have a crystal report, it has a group by statement based on two fields
Companyname
Account Type
Now Crystal report work and it does group by "companyname" but it does not group by "account type". I have two types of account, "Regular and Premium". One company has both type of account with us and it pulls on regular and not premium. What do you think is the issue.
I am new to crystal report. I am familiar with SQL Though. The differences that I see is
There is no aggregate function used for any column - in SQL an aggregate field is required to get meaningful result
There are about 10 fields in the report but group by is used only on two fields - in SQL you have to group by all fields if there are more than two fields
The group by fields are in the middle and in end - again in SQL the order of groupby field is important
In this case I am grouping by companyname first and then account status. Any insight will be helpful.
Note that I generated the equivalent SQL statement from Crystal Report. That query was ok except there were not group by statements. I added those and the aggregate column myself and I do get the same result as I am getting in Crystal (but the SQL report is more accurate as it does group by both the fields not just one).
Edit: Example Date. Each company can have multiple account of the same type. I want aggregate on "Company Name" and "AccountType" so that the data is listed as follow.
+----+--------------+-------------+------+
| ID | Company Name | AccountType | Sale |
+----+--------------+-------------+------+
| 1 | ABC | I | 500 |
| 2 | ABC | I | 600 |
| 3 | ABC | O | 1000 |
| 4 | ABC | O | 2000 |
| 5 | ABC | O | 3000 |
| 6 | XYZ | O | 2500 |
| 7 | LMN | O | 3400 |
+----+--------------+-------------+------+
Output I want from the above table is
+--------------+-------------+------+
| Company Name | AccountType | Sale |
+--------------+-------------+------+
| ABC | I | 1100 |
| ABC | O | 6000 |
| XYZ | O | 2500 |
| LMN | O | 3400 |
+--------------+-------------+------+
Update to incorporate comment discussion and revised question:
There are two basic options for resolving this issue:
1) Revise the SQL to perform the desired aggregation.
2) Within Crystal, add two groups, one for the company, then one for the account type.
Before you add groups in crystal, you have several standard sections, including the Report Header, Page Header, Details, Report Footer, and Page Footer.
If you do not perform grouping, each row that is read in the database will be displayed in the details section (technically, the entire details section is repeated for each row).
When you add the first group (Company), Crystal adds a Group Header #1 before the Details section and a Group Header #1 after the Details section.
If you run the report at this point, for each company Crystal will show the Group Header before each group of detail records associated with that company, then will show all of the detail records for that company, and finally, will shown the Group footer for that company.
Typically, the group header is used to display common information for that grouping that does not need to be repeated for each detail record. In this example, we could display the company name and other information related to the company.
Likewise, the group footer is typically used to display summary information for all of detail records displayed within that group.
In this case, we could add an aggregate that would summarize the Sale amount, which would be the total sales for that company, regardless of the account type.
When the second group is added, it will perform sub-grouping on the original group.
When the second group is added, Crystal will place a Group Header #2 below Group Header #1 and above the Details and will place a Group Footer # 2 directly below the details and above the Group Footer #1.
At this point, you have a report format similar to the following:
Group Header #1 (Company)
Group Header #2 (Account Type)
Details (the individual sale records)
Group Footer #2
Group Header #1
In this case, for each company, we want to group the details records by account type. So we can add information that describes the account type, if we want, to the Group Header #2 and we can add aggregates to Group Footer #2 to display totals for each account type within the company.
Now, if all that is desired is to show the totals for each account type within each company, then the only section that we need to show in the report is Group Footer #2. All of the fields (company, account type, sale aggregate) are available in this Footer, so we don't need any of the additional areas.