Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Charting data that does not exists Post Reply Post New Topic
Author Message
liddlem
Newbie
Newbie
Avatar

Joined: 06 Oct 2010
Location: Australia
Online Status: Offline
Posts: 10
Quote liddlem Replybullet Topic: Charting data that does not exists
    Posted: 05 Apr 2011 at 2:49pm

Hello readers
At the school where I work, we would like to represent individual student attendance as a pie chart (which is a sub-report on their academic report.)

The problem is that attendance is extremely eratic and we often have students arriving/enrolling many days into the term.
For various reasons, we are not able to backdate their absense prior to the first arrival day (each term) in the system.

So, based on the info in the following tables, I am able to create a pie chart showing ATTENDANCE and ABSENCE from the first arrived date, but how do I include the days prior to arrival in the chart.

eg Term starts 27/01/2011 and ends 07/04/2011
Excluding week-ends and public holidays, there are 52 school days in the term.
But the student only arrives on 03/03/2011, so will attend for a maximum of 25 schools days this term.
Actually, he has run away a few times, so attendance shows as
Attended : 16 days
Absent   : 9 days
But I want to be able to show that he arrives late and thus missed 27 days prior to arrival.

The database does have:
1. A calendar table (EBIZDW11_ATTCAL) identifying school days.
2. The Student list (EBIZDW11_STUDENT)
3. Actual attendance (EBIZDW11_ATTHST)
 
The following is the query that calculated attendance.
 
 SELECT "EBIZDW11_STUDENT"."CSTUDID", "EBIZDW11_ATTHST"."ATDATE", "EBIZDW11_ATTHST"."ATCODE", "EBIZDW11_ATTHST"."ATTYPE", "EBIZDW11_STUDENT"."SURNAME", "EBIZDW11_STUDENT"."CNAME", "EBIZDW11_ATTHST"."ATYEAR", "EBIZDW11_ATTCAL"."TERM", "EBIZDW11_ATTCAL"."ATSCHDAY"
 FROM   ("QUAD"."dbo"."EBIZDW11_ATTHST" "EBIZDW11_ATTHST" INNER JOIN "QUAD"."dbo"."EBIZDW11_STUDENT" "EBIZDW11_STUDENT" ON ((("EBIZDW11_ATTHST"."SCHREGN"="EBIZDW11_STUDENT"."SCHREGN") AND ("EBIZDW11_ATTHST"."SCHCDE"="EBIZDW11_STUDENT"."SCHCDE")) AND ("EBIZDW11_ATTHST"."CAMPUS"="EBIZDW11_STUDENT"."CAMPUS")) AND ("EBIZDW11_ATTHST"."STUDID"="EBIZDW11_STUDENT"."CSTUDID")) INNER JOIN "QUAD"."dbo"."EBIZDW11_ATTCAL" "EBIZDW11_ATTCAL" ON ("EBIZDW11_ATTHST"."ATYEAR"="EBIZDW11_ATTCAL"."ATYEAR") AND ("EBIZDW11_ATTHST"."ATDATE"="EBIZDW11_ATTCAL"."ATCALDAY")
 ORDER BY "EBIZDW11_STUDENT"."CSTUDID", "EBIZDW11_ATTHST"."ATDATE"
Hope this all makes sense?
Thanks for your input
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 Apr 2011 at 3:38am
Left outer join from the calendar table to the actual attendance table and from the attendance to the student.  (Table and join order is important here!)
 
Base the dates in your report on the dates from the calendar table.  To determine whether any given day is prior to when the student enrolled, you'll create a formula like the following:
 
If IsNull({EBIZDW11_ATTHST.ATDATE}) then "Pre-Enrollment"
else {EBIZDW11_ATTHST.ATCODE}
 
(Assuming that ATCODE contains info about present/absent/tardy.)
 
A left outer join means that you'll get all of the data from the table on the left (linked from) even if nothing exists that matches in the table on the right (linked to).  You need the left outer join from attendance to student because otherwise you'll only get the days the student actually attended.  If there is no attendance record for a date, then the student ID is null and you can't join from null to anything, thus the un-enrolled days won't come through in the query.
 
-Dell
IP IP Logged
liddlem
Newbie
Newbie
Avatar

Joined: 06 Oct 2010
Location: Australia
Online Status: Offline
Posts: 10
Quote liddlem Replybullet Posted: 07 Apr 2011 at 12:47pm
Thanks Hilfy
Looks like a good solution.
I will give that a whirl.
Thanks for your input
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.031 seconds.