Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Aligning Data Headers in Two Subreports Post Reply Post New Topic
Author Message
LauraRB
Newbie
Newbie
Avatar

Joined: 06 Nov 2013
Online Status: Offline
Posts: 6
Quote LauraRB Replybullet Topic: Aligning Data Headers in Two Subreports
    Posted: 06 Nov 2013 at 7:38am
I have a main report which contains 2 subreports.  The data for these two subreports is provided by the same very convoluted stored procedure.  At the subreport level, I filter the data that should be shown in each subreport:  The subreport on the left shows standard grades for each subject (grouped by student and subject/course).  The subreport on the right shows behavior marks for the same student/course/subject grouping.  The problem is that in the left report, Reading standards may have 6 line items while behavior has only 4.  That means when the Writing behavior "table" (the next subject to be displayed) shows up under reading, the headers of each table/subject are no longer lined up.  IE:
 
 
Reading header                              Reading behavior header
Effort                                              Preparation
Ideas and Content                           Participation
Demonstrates...                              Uses Time Wisley
Organization                                               
                                                    Writing Behavior header
Writing header                                 data                          
data                                                data
data
data                                              Math Behavior header
data                                                data
data
                                                  
I have since attempted to show both kinds of data in one subreport, suppressing the data I don't want to show in each table (ie suppressing behavior data in the left, suppressing anything that isn't behavior data in the right), and while I've succeeded in aligning the headers, the data in each side is giving space for data in the other side:
 
Reading header                             Reading behavior header
 Effort
 Ideas and Content
 Demonstrates...
 Organization
                                                   Preparation
                                                   Participation
                                                   Uses Time Wisely
 
Writing header                            Writing Behavior header
 data
 data
 data
 data
                                                   data
                                                   data
                                                   data
 
This would be easy to do in Reporting Services by using different data sources for each table.  Since CR doesn't have "tables" per se, this is way harder.
 
I also tried to use 2 different SP for each side of data (like I would have in RS), but CR really didn't like that because each SP does a whole lot of server-side grouping.
 
Currently, my one subreport is contained in the Details section of the main report.  The subreport has the left side data in Group Header #4a, right-side data in Group Header #4b.  I have suppress enabled on each group header section
(4a: {Reporting_StandardsBasedReportCard_2013;1.LearningStandardNumber} startswith "BE" OR
{Reporting_StandardsBasedReportCard_2013;1.Level} = 4)
(4b: not ({Reporting_StandardsBasedReportCard_2013;1.LearningStandardNumber} startswith "BE") OR
{Reporting_StandardsBasedReportCard_2013;1.Level} = 3)
 
and on each text item, but I am still getting spacing issues.  Help!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 06 Nov 2013 at 12:05pm
your stored procedure could return multiple 'tables' by having multiple SELECT statements. As long as you provide a field that you can link the tables on Crystal should be fine.

The other idea would be to use the same criteria for record selection in both subreports(so you have the same number of lines). Although this does assume that the behavior and the marks are the same lines.

If they aren't, there will always be a disconnect, and the multiple tables out of the stored proc is probably the best bet. if you are calling the report from an application, you could have the application call the stored proc and add rows to the behavior or the marks portion of the dataset (and of course you could split the dataset into multiple tables as well) so that they are the same.

HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Nov 2013 at 4:09am
only other option that comes to mind would be to use more grouping level (which also results in more subreport calls/draws).
I think your group would be on the 'behavior' and includ that as another link from main to sub report.


Edited by DBlank - 07 Nov 2013 at 4:10am
IP IP Logged
LauraRB
Newbie
Newbie
Avatar

Joined: 06 Nov 2013
Online Status: Offline
Posts: 6
Quote LauraRB Replybullet Posted: 13 Nov 2013 at 5:04am
Thanks for the replies.  Lockwelle, I have modified my SP to return two identical "tables" except that the first provides grades data and the second provides behavior.  They can be linked on CourseNumber, but again, for every course, the number of lines for grades will be different from the number of lines in behavior. 
 
Now my question is, how do I use thse two "tables" in CR? (I'm pretty new to CR, sorry!)
IP IP Logged
LauraRB
Newbie
Newbie
Avatar

Joined: 06 Nov 2013
Online Status: Offline
Posts: 6
Quote LauraRB Replybullet Posted: 13 Nov 2013 at 5:14am
Right now, I have updated my SP in CR and am returning rows, but it seems to be retunring rows only from the first (grades) table
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 13 Nov 2013 at 8:06am
have you tried Verify Database?

That should show the 2 tables, probably called table1 and table2. Then you can link the tables or really use them as you would any tables in Crystal.

HTH
IP IP Logged
LauraRB
Newbie
Newbie
Avatar

Joined: 06 Nov 2013
Online Status: Offline
Posts: 6
Quote LauraRB Replybullet Posted: 13 Nov 2013 at 8:11am
No, it just shows the title of my SP (Reporting_StandardsBasedReportCard_2013;1) and the fields (listed only once) from the firts table.  This is my SP:
 
USE [D_150000]
GO
/****** Object:  StoredProcedure [dbo].[Reporting_StandardsBasedReportCard_2013]    Script Date: 11/13/2013 07:54:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Reporting_StandardsBasedReportCard_2013]
(
    @StudentId              BIGINT,
    @CalendarId             BIGINT,
    @Term                   TINYINT,
    @Language          CHAR(2)
)
AS
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SELECT
    MIN(EnrollmentStatus.[Status])          AS [Status],
    CASE
        WHEN LEN(ISNULL(AlternateCourseCode,''))=0  THEN Course.Code
        ELSE AlternateCourseCode
    END                                     AS CourseNumber,
    Section.LocalId                         AS SectionNumber,
    rpt.TruncateExtraData(Course.Name, '0') AS CourseDescription,
    RptGradingTerm.ReportCode,
    CASE
        WHEN GradebookTermGrade.OverrideCode IS NOT NULL
        THEN GradebookTermGrade.OverrideCode
        ELSE GradebookTermGrade.Letter
    END                                     AS Letter,
    LearningStandard.StatementCode          AS LearningStandardNumber,
    Person.LastName                         AS PrimaryTeacherLastName,
    Person.FirstName                        AS PrimaryTeacherFirstName,
    EnrollmentStatus.CalendarId,
    EnrollmentStatus.StudentId,
    LearningStandardLevel.Number            AS [Level],
    RptGradingTerm.GradingTermId,
    lss.[Numeric]         AS [Numeric],
    lss.Letter            AS LearningStandardScoreLetter,
    LearningStandardStatement.[Language]    AS [Language],
    Predecessor.StatementCode               AS PredecessorLearningStandardNumber,
    rpt.TruncateExtraData(LearningStandardStatement.[Statement], '-')   AS [Statement],
    rpt.GetFullname(NULL,NULL,Person.LastName,Person.FirstName,Person.MiddleName,Person.Prefix) AS TeacherFullname,
    CASE
  WHEN LearningStandard.StatementCode like 'BE%'
  THEN
   CASE
    WHEN (Course.Name like 'LANGUAGE%' or Course.Name like 'WRITING%' or Course.Name like 'READING%'or Course.Name like 'SPEAKING%')
    THEN 1
    WHEN Course.Name like 'MATH%' THEN 2
    WHEN Course.Name like 'SOCIAL%' THEN 4
    WHEN Course.Name like 'SCIENCE%' THEN 3
    WHEN Course.Name like 'HEALTH%' THEN 5
    WHEN Course.Name like 'PHYSICAL%' THEN 6
    WHEN Course.Name like 'MUSIC%' THEN 7
    WHEN Course.Name like 'ART%' OR Course.Name like 'TECH%' THEN 8
    ELSE LearningStandard.Sequence    
   END            
  ELSE LearningStandard.Sequence      
 END          AS Sequence,
STUFF(
   (SELECT '; ' + gs.BreakpointDescription FROM RptTermComment tc
   INNER JOIN RptGradingScale gs ON gs.GradingScaleId=tc.GradingScaleId AND gs.Letter=tc.Code
   JOIN RptGradingTerm gt1 ON gt1.CalendarId=@CalendarId --AND gt1.ReportCode=@ReportCode
   WHERE StudentId=@StudentId AND tc.GradingTermId=gt1.GradingTermId
   AND tc.SectionEnrollmentId=lss.SectionEnrollmentId
   FOR XML PATH('')),1,1,'' ) AS CannedComments,
(select     a1.Comments
from       AssignmentScore a1
inner join Assignment a2
on        a1.AssignmentId = a2.AssignmentId
inner join Gradebook g3
on        a2.GradebookId = g3.GradebookId
where      a2.ShowInView = '4' and StudentId=@StudentId and a2.gradebookid = GradebookTerm.GradebookId
)
as notes
FROM
    rpt.ComputeEnrollmentStatus (@CalendarId, NULL, @StudentId) AS EnrollmentStatus
        INNER JOIN Section ON Section.SectionId = EnrollmentStatus.SectionId
        INNER JOIN Course ON Course.CourseId = Section.CourseId
        INNER JOIN Teacher ON Teacher.TeacherId = Section.PrimaryTeacherId
        INNER JOIN Person ON Person.PersonId = Teacher.PersonId
        INNER JOIN RptGradingTerm ON RptGradingTerm.GradingTermId = EnrollmentStatus.GradingTermId
        INNER JOIN rpt.GenerateTermReportCodes(@Term, 'Q') ReportCodes ON RptGradingTerm.ReportCode = ReportCodes.ReportCode
        INNER JOIN GradebookTerm ON GradebookTerm.GradebookId = Section.GradebookId
                    AND GradebookTerm.GradingTermId=RptGradingTerm.GradingTermId
        LEFT OUTER JOIN GradebookTermGrade ON GradebookTermGrade.GradebookTermId=GradebookTerm.GradebookTermId
            AND GradebookTermGrade.StudentId = EnrollmentStatus.StudentId
        INNER JOIN LearningStandardLink ON LearningStandardLink.CourseOfferingId = Section.CourseOfferingId
            AND LearningStandardLink.GradingTermId=EnrollmentStatus.GradingTermId
        INNER JOIN LearningStandard ON LearningStandard.LearningStandardId = LearningStandardLink.LearningStandardId
        INNER JOIN LearningStandardStatement ON LearningStandard.LearningStandardId = LearningStandardStatement.LearningStandardId
        INNER JOIN LearningStandardLevel ON LearningStandardLevel.LearningStandardLevelId = LearningStandard.LearningStandardLevelId
        LEFT OUTER JOIN LearningStandard Predecessor ON Predecessor.LearningStandardId = LearningStandard.LearningStandardPredecessorId
        LEFT OUTER JOIN RptLearningStandardScore lss ON lss.LearningStandardId = LearningStandardLink.LearningStandardId
            AND lss.SectionEnrollmentId = EnrollmentStatus.SectionEnrollmentId
            AND lss.GradingTermId = LearningStandardLink.GradingTermId
WHERE
    LearningStandard.IsDeleted = 0
    AND LearningStandardStatement.[Language] = @Language
 AND Course.Code <> '996'
 AND LearningStandardLevel.Number = 3
 AND Course.Name not like '%Homeroom%'
 AND LearningStandard.StatementCode not like 'BE%'
GROUP BY
    AlternateCourseCode,
    Course.Code,
    Section.LocalId,
    Course.Name,
    RptGradingTerm.ReportCode,
    GradebookTermGrade.OverrideCode,
    GradebookTermGrade.Letter,
    LearningStandard.StatementCode,
    Person.LastName,
    Person.FirstName,
    EnrollmentStatus.CalendarId,
    EnrollmentStatus.StudentId,
    LearningStandardLevel.Number,
    RptGradingTerm.GradingTermId,
    lss.[Numeric],
    lss.Letter,
    LearningStandardStatement.[Language],
    Predecessor.StatementCode,
    LearningStandardStatement.[Statement],
    Person.LastName,
    Person.FirstName,
    Person.MiddleName,
    Person.Prefix,
    LearningStandard.sequence,
 lss.SectionEnrollmentId,
 lss.[Level],
 GradebookTerm.GradebookId
ORDER BY
 LearningStandard.sequence
SELECT
    MIN(EnrollmentStatus.[Status])          AS [Status],
    CASE
        WHEN LEN(ISNULL(AlternateCourseCode,''))=0  THEN Course.Code
        ELSE AlternateCourseCode
    END                                     AS CourseNumber,
    Section.LocalId                         AS SectionNumber,
    rpt.TruncateExtraData(Course.Name, '0') AS CourseDescription,
    RptGradingTerm.ReportCode,
    CASE
        WHEN GradebookTermGrade.OverrideCode IS NOT NULL
        THEN GradebookTermGrade.OverrideCode
        ELSE GradebookTermGrade.Letter
    END                                     AS Letter,
    LearningStandard.StatementCode          AS LearningStandardNumber,
    Person.LastName                         AS PrimaryTeacherLastName,
    Person.FirstName                        AS PrimaryTeacherFirstName,
    EnrollmentStatus.CalendarId,
    EnrollmentStatus.StudentId,
    LearningStandardLevel.Number            AS [Level],
    RptGradingTerm.GradingTermId,
    lss.[Numeric]         AS [Numeric],
    lss.Letter            AS LearningStandardScoreLetter,
    LearningStandardStatement.[Language]    AS [Language],
    Predecessor.StatementCode               AS PredecessorLearningStandardNumber,
    rpt.TruncateExtraData(LearningStandardStatement.[Statement], '-')   AS [Statement],
    rpt.GetFullname(NULL,NULL,Person.LastName,Person.FirstName,Person.MiddleName,Person.Prefix) AS TeacherFullname,
    CASE
  WHEN LearningStandard.StatementCode like 'BE%'
  THEN
   CASE
    WHEN (Course.Name like 'LANGUAGE%' or Course.Name like 'WRITING%' or Course.Name like 'READING%'or Course.Name like 'SPEAKING%')
    THEN 1
    WHEN Course.Name like 'MATH%' THEN 2
    WHEN Course.Name like 'SOCIAL%' THEN 4
    WHEN Course.Name like 'SCIENCE%' THEN 3
    WHEN Course.Name like 'HEALTH%' THEN 5
    WHEN Course.Name like 'PHYSICAL%' THEN 6
    WHEN Course.Name like 'MUSIC%' THEN 7
    WHEN Course.Name like 'ART%' OR Course.Name like 'TECH%' THEN 8
    ELSE LearningStandard.Sequence    
   END            
  ELSE LearningStandard.Sequence      
 END          AS Sequence,
STUFF(
   (SELECT '; ' + gs.BreakpointDescription FROM RptTermComment tc
   INNER JOIN RptGradingScale gs ON gs.GradingScaleId=tc.GradingScaleId AND gs.Letter=tc.Code
   JOIN RptGradingTerm gt1 ON gt1.CalendarId=@CalendarId --AND gt1.ReportCode=@ReportCode
   WHERE StudentId=@StudentId AND tc.GradingTermId=gt1.GradingTermId
   AND tc.SectionEnrollmentId=lss.SectionEnrollmentId
   FOR XML PATH('')),1,1,'' ) AS CannedComments,
(select     a1.Comments
from       AssignmentScore a1
inner join Assignment a2
on        a1.AssignmentId = a2.AssignmentId
inner join Gradebook g3
on        a2.GradebookId = g3.GradebookId
where      a2.ShowInView = '4' and StudentId=@StudentId and a2.gradebookid = GradebookTerm.GradebookId
)
as notes
FROM
    rpt.ComputeEnrollmentStatus (@CalendarId, NULL, @StudentId) AS EnrollmentStatus
        INNER JOIN Section ON Section.SectionId = EnrollmentStatus.SectionId
        INNER JOIN Course ON Course.CourseId = Section.CourseId
        INNER JOIN Teacher ON Teacher.TeacherId = Section.PrimaryTeacherId
        INNER JOIN Person ON Person.PersonId = Teacher.PersonId
        INNER JOIN RptGradingTerm ON RptGradingTerm.GradingTermId = EnrollmentStatus.GradingTermId
        INNER JOIN rpt.GenerateTermReportCodes(@Term, 'Q') ReportCodes ON RptGradingTerm.ReportCode = ReportCodes.ReportCode
        INNER JOIN GradebookTerm ON GradebookTerm.GradebookId = Section.GradebookId
                    AND GradebookTerm.GradingTermId=RptGradingTerm.GradingTermId
        LEFT OUTER JOIN GradebookTermGrade ON GradebookTermGrade.GradebookTermId=GradebookTerm.GradebookTermId
            AND GradebookTermGrade.StudentId = EnrollmentStatus.StudentId
        INNER JOIN LearningStandardLink ON LearningStandardLink.CourseOfferingId = Section.CourseOfferingId
            AND LearningStandardLink.GradingTermId=EnrollmentStatus.GradingTermId
        INNER JOIN LearningStandard ON LearningStandard.LearningStandardId = LearningStandardLink.LearningStandardId
        INNER JOIN LearningStandardStatement ON LearningStandard.LearningStandardId = LearningStandardStatement.LearningStandardId
        INNER JOIN LearningStandardLevel ON LearningStandardLevel.LearningStandardLevelId = LearningStandard.LearningStandardLevelId
        LEFT OUTER JOIN LearningStandard Predecessor ON Predecessor.LearningStandardId = LearningStandard.LearningStandardPredecessorId
        LEFT OUTER JOIN RptLearningStandardScore lss ON lss.LearningStandardId = LearningStandardLink.LearningStandardId
            AND lss.SectionEnrollmentId = EnrollmentStatus.SectionEnrollmentId
            AND lss.GradingTermId = LearningStandardLink.GradingTermId
WHERE
    LearningStandard.IsDeleted = 0
    AND LearningStandardStatement.[Language] = @Language
 AND Course.Code <> '996'
 AND LearningStandardLevel.Number = 4
 AND Course.Name not like '%Homeroom%'
 AND LearningStandard.StatementCode like 'BE%'
GROUP BY
    AlternateCourseCode,
    Course.Code,
    Section.LocalId,
    Course.Name,
    RptGradingTerm.ReportCode,
    GradebookTermGrade.OverrideCode,
    GradebookTermGrade.Letter,
    LearningStandard.StatementCode,
    Person.LastName,
    Person.FirstName,
    EnrollmentStatus.CalendarId,
    EnrollmentStatus.StudentId,
    LearningStandardLevel.Number,
    RptGradingTerm.GradingTermId,
    lss.[Numeric],
    lss.Letter,
    LearningStandardStatement.[Language],
    Predecessor.StatementCode,
    LearningStandardStatement.[Statement],
    Person.LastName,
    Person.FirstName,
    Person.MiddleName,
    Person.Prefix,
    LearningStandard.sequence,
 lss.SectionEnrollmentId,
 lss.[Level],
 GradebookTerm.GradebookId
ORDER BY
 LearningStandard.sequence
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 13 Nov 2013 at 8:25am
Sorry about that...What I have done in the past have a stored proc that returned multiple tables. I would then pass the resulting dataset from an application to the report, and I would see the 2 tables.

Having just tried my suggestion...it doesn't work as you noticed. What you can do is make you stored proc only return once, but you can select it twice in the Database Expert. You will only have to enter the parameters once, and you will be able link the resulting tables as desired.

Sorry for the misinformation.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.035 seconds.