I am trying to create a report to show our overall quality tending over time by month or quarter (over a span of several years). The main report will show all of our shipments over the specified time period grouped by month/quarter, and the sub report will show all returns entered during that month/quarter that result in scrap or rework.
The issue I am having is linking the sub report to the date group in the main report. After several attempts using different methods, the best I could do is show all returns within the date parameter in every group footer.
This is my first time posting, so I'm not sure what additional info will be needed to assist. Please let me know if there is more needed.
*Edit for additional info
I would like the subreport to show data for each month or quarter in the given time period. So if the date range of the report is for 1/1/2018 - 9/30/2018 and the data is grouped by month, I would like the subreport to show only the data from each month group. General layout below.
January
Shipments
Returns (subreport showing data for January)
February
Shipments
Returns (subreport showing data for February)
*Second edit to add screenshot and more info
I stripped all the parameters from the subreport because I couldn't get any of them to work. The only parameter on the main report is the Date Range that prompts users for a start and end date.
The main report has the shipments in the details section.
Current layout below. If I can get this current issue resolved, I will be adding values passed up from the subreport to calculate the quality rating for each month, then passing them back down to a second subreport to summarize and chart.
Quality Trend Layout
*Third edit for data source and example data
The main and subreports are pulled from tables in our company database.
SQL query used for the main report. Only the "Releases" table is used to show how many and when each part was shipped. DelType=0 is specifying a customer delivery. The date range is defined by a user entered parameter.
Main Report
SELECT
"Releases"."DateComplete",
"Releases"."DelType",
"Releases"."PartNo",
"Releases"."Qty",
"Releases"."JobNo",
"Releases"."PartDesc"
FROM "COMPANY"."dbo"."Releases" "Releases"
WHERE "Releases"."DelType"=0 AND
("Releases"."DateComplete">={ts '2018-01-01 00:00:00'} AND
"Releases"."DateComplete"<{ts '2018-10-01 00:00:00'})
I am trying to use CustReturn.DateEnt as the datetime link to Releases.DateComplete in the main report (not currently linked at a paramter because it didn't work), and only select records that are customer returns resulting in rework, scrap, sort, or repair.
Subreport
SELECT
"CustReturn"."DateEnt",
"CustReturn"."CustRMANo",
"CustReturnDet"."OrigJobNo",
"CustReturnDet"."PartNo",
"CustReturnDet"."QtyReturned",
"CustReturnDet"."QtyToRework",
"CustReturnDet"."QtyToRestock",
"NonConformance"."Disposition",
"NonConformance"."ReturnType",
"CustReturn"."IssueDate",
"NonConformance"."NonConfDate",
"CustReturnDet"."PartDesc"
FROM
("COMPANY"."dbo"."CustReturn" "CustReturn" INNER JOIN "COMPANY"."dbo"."CustReturnDet" "CustReturnDet" ON "CustReturn"."CustRMANo"="CustReturnDet"."CustRMANo")
LEFT OUTER JOIN "COMPANY"."dbo"."NonConformance" "NonConformance" ON "CustReturnDet"."NonConfNo"="NonConformance"."NonConfNo"
WHERE ("NonConformance"."Disposition"='REPAIR' OR
"NonConformance"."Disposition"='REWORK' OR
"NonConformance"."Disposition"='SCRAP' OR
"NonConformance"."Disposition"='SORT') AND
"NonConformance"."ReturnType"='CUSTOMER'
Quality Trend Example Data
First, I want to give a big thanks to Digital.Aaron. Your help in solving this is greatly appreciated.
Your answer was quite close to what I needed. I was still unable to get the subreport to show any data after adding the additional lines to the SQL statement, so I tried something a little different. I made the additional statements into formula fields.
Main Report Field
DATEADD("D", -1*(DATEPART("D",{Releases.DateComplete})-1),{Releases.DateComplete})
Subreport Field
DATEADD("D", -1*(DATEPART("D",{CustReturn.DateEnt})-1),{CustReturn.DateEnt})
I used these fields as the link between the main report and subreport, but still couldn't get the data to show. The issue turned out to be setting them as = to each other in the record select formula of the subreport. I named the formulas DatePeriod
Original Record Select
{#DatePeriod} = {?Pm-#DatePeriod}
Modified Record Select
{#DatePeriod} in Date({?Pm-#DatePeriod})
Once I made the change, everything fell into place.
Thanks again,
Jeff
So it looks like you're grouping on Releases.DateComplete. Let's assume this value is the same for all records associated with a given month. Let's also assume the following (simplified) sample data for Shipments:
ShipmentDate | PartNo | Qty | DateComplete
01/01/2018 | 0001 | 1 | 01/31/2018
01/05/2018 | 0031 | 10 | 01/31/2018
01/31/2018 | A314 | 4 | 01/31/2018
Your Returns data would then need to look something like this:
ReturnDate | PartNo | Qty | DateComplete
01/15/2018 | 0031 | 7 | 01/31/2018
Notice they both have a DateComplete column.
Now in your Crystal Report template, you'll use the DateComplete field from the main report results set as the input to your subreport parameter. Your design layout looks like it would be correct here, as you'll want the subreport to be called in the group footer.
EDIT: So it looks like DateComplete is not the same for all records in a given month. That's fine. We're going to add a column to both the main query and the subreport query that WILL be the same for all records in a given month, and that we can then use to link the records.
Your main query would become:
SELECT
Releases.DateComplete,
Releases.DelType,
Releases.PartNo,
Releases.Qty,
Releases.JobNo,
Releases.PartDesc,
DatePeriod = DATEADD(DAY, -1*(DATEPART(DAY,Releases.DateComplete)-1),Releases.DateComplete)
FROM COMPANY.dbo.Releases Releases
WHERE Releases.DelType=0
AND (Releases.DateComplete>={ts '2018-01-01 00:00:00'} AND Releases.DateComplete<{ts '2018-10-01 00:00:00'})
Your subreport query would then become:
SELECT
CustReturn.DateEnt,
CustReturn.CustRMANo,
CustReturnDet.OrigJobNo,
CustReturnDet.PartNo,
CustReturnDet.QtyReturned,
CustReturnDet.QtyToRework,
CustReturnDet.QtyToRestock,
NonConformance.Disposition,
NonConformance.ReturnType,
CustReturn.IssueDate,
NonConformance.NonConfDate,
CustReturnDet.PartDesc,
DatePeriod = DATEADD(DAY, -1*(DATEPART(DAY,CustReturn.DateEnt)-1),CustReturn.DateEnt)
FROM COMPANY.dbo.CustReturn CustReturn
INNER JOIN COMPANY.dbo.CustReturnDet CustReturnDet ON CustReturn.CustRMANo = CustReturnDet.CustRMANo
LEFT OUTER JOIN COMPANY.dbo.NonConformance NonConformance ON CustReturnDet.NonConfNo = NonConformance.NonConfNo
WHERE NonConformance.ReturnType='CUSTOMER'
AND (
NonConformance.Disposition='REPAIR'
OR NonConformance.Disposition='REWORK'
OR NonConformance.Disposition='SCRAP'
OR NonConformance.Disposition='SORT'
)
DatePeriod will always be the date of the first day of the month. Now we can use this as the Link field between the main report and the subreport. You could also consider making this the field that you Group on, instead of the month value.
I am running Crystal Reports 11 and I have a report that has 7 subreports that it pulls and when done, is multiple pages long. I have three parameters I ask for. I want to change one of the parameters to allow multiple fields so I don't have to keep refreshing it but I want the report to repeat for each field value I add.
Example, the report asks for month. I want to put in January, February and March into the field value. The report then should run for each of those months and give me one large report where January and all January data is back to back and then goes to February, etc.
Is this possible?
Thanks.
Jayson
Group the report at level one by Month.
In the Group Options tab (or in the GF1 section), turn on the 'New Page After' option.
I'm relatively new to Crystal Reports and it seems like this should be easy, but I haven't been able to figure it out after a lot of googling. I'm working on a report in Crystal Reports XI that will show total hours logged by support staff for a date range and show sub totals by week, month, or both depending on the user input. My report is currently arranged as follows:
Group 1 Header - Support Staff Member
Group 2 Header - Ticket Closed Date with section printed monthly
Group 3 Header - Ticket Closed Date with section printed weekly
Group 4 Header - Ticket Category
Group 4 Footer - Sum of time logged in each category for the week
Group 3 Footer - Sum of time logged in all categories for the week
Group 2 Footer - Sum of time logged in all categories for the month
Group 1 Footer - Sum of all time logged
My original idea was just to suppress the header and footer for groups 2 and 3 when they weren't needed, but if I manually do that it still prints the records by week and month. Is there a way to not have the grouping at all unless the parameter says to show those totals? Or if that isn't an option, how would I use the parameter to change whether the group prints records weekly or monthly?
Thank you
Best option would be create a string parameter 'option' with values weekly and monthly.
Now create a formula grouping.
If ?parameter='weekly'
Then //your weekly code here
Else if ?parameter='monthly'
Then //your monthly code
Now use this formula in grouping instead of multiple groups.
Now when user selects option your grouping will change dynamically.
Hope this helps
I am new to crystal.
I have to show the top 217 items based on the quantities shipped in 2014 and side by side 2013.
Is there way to put in one report the data.
Item1 in 2103 may not be the same as 2014.
I get the data from invoice history detail table, and add the qty shipped from all item and then sort the top 217 items on basis of the sum.
I can have them in 2 reports or the previous year data from sub-report,but then the sub report data will appear as row after the current year. however how can I put them in 1 report side by side for a better comparison.
Thanks for your help
Steps:
Create a report that does what you want for a single year (say 2013)--you'll probably want to use a top-N grouping.
Create a second report, without a datasource
import the first report into the second one (call it 'year N-1'); don't link the sub-report to the main
import the first report into the second report a second time (call it 'year N'); don't link the sub-report to the main
edit the second sub-report and set the date to 2014
If you want the report to be more flexible, create a parameter in the main report (named 'year'). Link this parameter to each of the sub-reports, changing the respective, record-selection formulas to use the value to calculate the correct date ranges.
This must be simple, yet I can't seem to find an answer.
I have a simple Query:
SELECT InvoiceTotal, InvoiceDate, InvoiceNoUnit from InvoiceLineItem
Which I want to display in Crystal Reports from my App. Rather than build many reports, I want to be able to have the user change a parameter that allows the resulting report to be grouped by date, based on the level of granularity selected by the user.
EG: I want the user to be able to select "By Month" and the report is grouped by Month (with corresponding Chart displayed by month. Then the user runs the report "by week" and the report changes to group by week.
I want them to select this in my app, and for me to pass a parameter to CR to change the grouping.
Any suggestions?
You can create a parameter where the user selects "Year", "Month", "Day" etc.
From there, you can create a formula that specifies the grouping based on the parameter above, and then create a Grouping in the report that uses this formula to group by.
I don't have Crystal Reports handy, but the formula could look something like this:
IF #UserDefinedGrouping = "Year" THEN
DATEPART(yyyy, {Table.InvoiceDate})
ELSEIF #UserDefinedGrouping = "Month" THEN
DATEPART(m, {Table.InvoiceDate})
ELSEIF #UserDefinedGrouping = "Quarter" THEN
DATEPART(q, {Table.InvoiceDate})
' etc...