Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Averages, minimums, and null values

edited June 2002 in General
Hi,

We want to report average and minimum scores for a number of people for
several tests, where not everyone has taken every test. Anyone who did not
take a test has a null value in the field for that test in their record.

If we use a TppDBCalc object with no modifications, we get 0 as the minimum
if anyone did not take a test, because Null is getting treated as 0.
Similarly, the average uses the record count as its divisor, so the average
we get is not the one we want, if there are records with no score for a
test.

Also, 0 is a valid score, and is not the same as not taking the test, so we
need to be able to distinguish the two.

Is this a case where we need to calculate the values ourselves, rather than
asking RBuilder to do it?

Thanks.

Mike Carroll

Comments

  • edited June 2002
    Use TppVariables and code their OnCalc event handlers to check the
    datapipeline field value in order to determine if this record value is null
    or not. If it isn't null, then you can increment the value of one of the
    TppVariables (the one used as the count). Then in the other OnCalc event
    handler, increment the total value of the total TppVariable. You can do
    this for the minimum and maximum fields also with variables. Check for null
    and then compare it to the running minimum and maximum values. Use a
    TppVariable for each infdividual calculation, instead of using TppDBCalcs.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited July 2002
    DBCalc should treat NULL values correctly,
    now it is almost useless !. Can you fix this ?


    On Mon, 17 Jun 2002 12:57:43 -0500, "Jim Bennett \(Digital
  • edited July 2002
    The DBCalc treats the null data as valid records when it counts. To get
    different behavior, you'll have to code a TppVariable's OnCalc event handler
    and make the variable skip nulls and include zeros when calculating.


    Cheers,

    Jim Bennett
    Digital Metaphors Corp.

This discussion has been closed.