If I had a single table of items ordered (let's call the table "items"), and there was a column within the table that tied the items in the same order together (order_id), how would I select all orders that contained a certain "key" item?
In other words, I want to select orders that contain the "key" item and I want to see all the items with in that order, not just the "key" item.
For example, I want to select all grocery orders (and all the items within) where the person at least ordered "apples".
You could probably (although I haven't tested it):
Add your table twice (so you will have two aliases pointing to the same table: table_1, table_2), joining on order_id
In your selection formula, use {table_1.key} = "apples"
Add a group on {table_1.order_id}
Use fields from table_2 for the detail section
Alternatively, add the table once, select on {table.key} = "apples" and group by {table.order_id}. Add a subreport in the group header linked by {table.order_id} to display the items. This will be slower, but it will definitely give you what you want.
Related
Working with vehicle asset management and I am selecting data based on two statements:
({EQ_MAIN.PROCST_PROC_STATUS} in ["A", "AS", "AT"] and
{EQ_MAIN.DEPT_DEPT_CODE} like "P*" and
{EQ_MAIN.ASSET_TYPE} <> "COMPONENT")
or
({EQ_MAIN.PROCST_PROC_STATUS} in ["TA"] and
{EQ_MAIN.DEPT_TEMP_LOANED_TO} like "P*" and
{EQ_MAIN.ASSET_TYPE} <> "COMPONENT")
Basically, if the Equipment is in status A, AS, or AT and belongs to the departments that start with P, I want it to show on the report. However, the second part of the selection statement accounts for equipment that is temporarily loaned to another department (status TA). The selection statements seem to be working fine.
I have this data grouped by {EQ_MAIN.DEPT_DEPT_CODE}. But I want it to to include any temporarily loaned out equipment under the department group, if the equipment is on temp loan to said department. For example, Car A belongs to department K1234, but is on loan to department P5678. I want Car A to show up under the group for P5678 along with all the other vehicles that belong to P5678. Essentially, whether a piece of eq belongs to a specific department or is simply on loan to said specific department, I want to see them under the same group in Crystal. Thoughts?
I do not believe that a grouping formula is the solution for this scenario. The challenge is based in the recordset. Since there is only one LOANED_TO record per DEPT_CODE, you can go about this a couple of ways.
If this is an option, modify your query or view so that you generate all LOANED_TO records for each DEPT_CODE. This could be achieved by placing a subquery in your FROM clause if using SQL. Then, join your parent table EQ_MAIN to the subquery on a non-unique, general key. Since there is no one-to-one relationship in this scenario, you should get all LOANED_TO records for each DEPT_CODE. This will, however, bloat your recordset and mar performance.
Then, group the report first on {DEPT_CODE} and second on {LOANED_TO}. Use a suppression formula on the second group to hide any {LOANED_TO} Departments that do not match the parent group {DEPT_CODE}.
The more "traditional" Crystal approach is to group on {DEPT_CODE}. Then, add a sub report to a group section. Using the same datasource, move the second chunk of selection criteria (following the OR clause) to the sub report record selection. This will return all {LOANED_TO} records. Add a sub report link between the group {DEPT_CODE} and the sub report {LOANED_TO} dept. This will filter results to just those {LOANED_TO} records related to the main group.
Currently I can group just by one field not by two fields in a cross-tab
You should create a formula field that concatenates the text of these two fields, then use that formula as the field that you group on.
For reports, you just select Insert > Group and add a second group. For crosstabs, just add them to the Rows section.
If you want to have two physically separate statuses ("Temporary" and "Permanent") like in the picture, you'll want two physically separate crosstabs (the second of which will need to be in a subreport).
It would be easier to have one crosstab and just add the Status to the Row section.
I am using iReport 4.1.3. I have created invoice report and I want to have 3 copies of same invoice report. The first invoice should have label as "ORIGINAL", second should have "DUPLICATE" and the third should have label as "TRIPLICATE" on it.
Thank you.
If you would like to show all three copies every time you open the report, here is a creative if not elegant solution.
Add a cross join to the FROM clause of your query returning the three different copies. In MySQL it looks like this:
CROSS JOIN
(
Select 'ORIGINAL' as copy, 1 as sequence
UNION
SELECT 'DUPLICATE' as copy, 2 as sequence
UNION
SELECT 'TRIPLICATE' as copy, 3 as sequence
) x
Then add the "copy" field to your select statement. This will cause your query to return 3 records for each record it was previously returning. One record with "ORIGINAL" in the copy field, one with "DUPLICATE" and one with "TRIPLICATE". Add "sequence" to your ORDER BY clause.
Then in the report, group by the "copy" field. Force a new page for each group and you should be all set. Any variables you are totaling at the report level you will need to change to the group level ("copy" group). And if you have any controls in the Summary section, move them to the new group footer section. Also create a text field to display the "copy" field in the page or group header.
It's not necessarily pretty, but it should work.
I have a report that currently lists data of a parent and its the details on the same row. So lets say the columns of the parent group take up the first three columns and the details the next three. Currently the first three columns span the height of the combined details rows. So if there are three detail rows the first three columns are one row that spans the height of these three columns. This is how I initially wanted it.
Now what I would like to do is list the first row of the parent group, then under that list the details, then the next row of the parent group and under that its details and so on.
An example just in case i'm not clear
CategoryId and Category Name are the parent columns
ProductId ProductName and Price are the details, and these are linked to the category by a categoryId
I want to display the first category row, then under that each product in this category, then the next category row and under it the products, then the next category etc.
Is this possible?
Thanks,
Neil
What you are looking for is called a stepped report. Here is a good guide on how to create one in SSRS 2008: How to: Create a Stepped Report.
From the webpage:
A stepped report shows detail rows or child groups indented under a
parent group in the same column, as shown in the example below:
I believe you are asking for:
Category 1 | Category A
Product A01 | $1
Product A02 | $2
Category 2 | Category B
Product B01 | $1
Product B02 | $2
You could try placing the matrix/table in a list which is grouped by category
List grouped by category id[
Table header row [ category id | category name ]
Table detail row [ productname | product price ]
]
Hope that makes sense. I predominately use SSRS2005 where there are many shortcomings like this (I put tables in lists and header tables in table cells etc etc). SSRS2008 could have another solution.
I opted for a solution using sub-reports. So I display the first three columns on the first row, then on the next (repeating) row I have a sub report which takes the categoryId and displays the products based on the ID passed into it. Works as I want it to
Is it possible to have add a row to an SSRS 2008 Matrix that spans all of the matrix's columns?
This crude diagram shows roughly what I'm looking for:
The basic idea is that each line item is a person, and each column is a field in a form for that person. The fields themselves are dynamic (and implemented as column groups on the matrix). Additional column groups are included to append non-dynamic form fields, like the time the record was entered and who entered it. Under each person's record is a comments field, which should span all of the form fields above it.
At the moment I have the matrix embedded in another tablix, with the name and fields in the matrix and the comments in the parent tablix. This works for the data (each instance of the matrix ends up being one row), but the header repeats too often (once per person) because it's attached to the matrix. The only thought I have as to how to fix this is to create another matrix in the parent tablix with the same grouping and use it to display the headers... But this will require quite a lot of manual synchronization to keep the two matrices the same.
Edit: The key problem here is making the second row span multiple column groups.
Here's what you can do:
Select the column grouping you want to add above and right click and select
Add Group... Parent Group...
Group the column by something that will not aggregate the data. You'll have to select a field from your dataset to group by so that it creates an overlapping column grouping.
Check the Add group header box
You should now see something similar to this:
Now you just need to move the Value1 field and it's header over under the new column to the right beyond the matrix dividers. Once that's done, simply delete the ungrouped column where you just copied Value1 from and be sure to select Delete columns only checkbox.
Your finished product should look like this:
It is possible - And the above answers are partial answers leaving out one key step: Merging the cells of the child row.
First, right click on your grouped row, then select Insert Row -> Inside Group - Below and you will get two rows with the cells aligning on the columns
Second, ctrl click all the cells in your new row (ie row without the data) then right click on one of the highlighted cells, and then select Merge Cells.
Now you have the table you like. To add a value to the new row: first right click your new (multi column) cell,select Create Placeholder, and then add the dataset item you desire to the placeholder.
[Edit]
After several attempts, I'm going to say this isn't possible in SSRS. The best I could come up with is a group footer that spans columns 1,2, and 3, but not the User column.
[Original Response]
I recently did something similar to this.
First, what tool are you using to create SSRS reports? (I used SQL Server Business Intelligence Development Studio)
You'll want to create a row group (grouped on Person)
Append a row to your table in "Design" view (Right click, "Insert Row --> Inside Group - Below").
Add an expression to the row that pulls the value for your "Comment" column (=Fields!Comment.Value).
Let me know if that helps...
Try adding in you column group "header" with a grouping expression of (1=1). Then a detail field will need to be defined. If you define the other group with correct data then the "header" will stretch across all details columns. You may need to merger depending on other options.
The easiest way to do this is to create a Tablix with only one column, and your row grouping.
Then, you create two rows inside this group.
In the first row inside the group, you insert a Matrix, wich you can then subgroup as you prefer.
I just had a similar problem, and this was my solution.
I banged my head against the wall for a lot of time, until i realized the solution to my problem wasn't "making a cell span multiple column groups", but "making a cell split into multiple column groups".
You can accomplish the goal by using a subreport for each person. The subreport will receive the employee id and create the hierarchy for you. Make sure your subreport column widths match the widths of the parent report.