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

Details as a percentage of a Group Header total

edited April 2003 in General
I seem to have lost my way on this one! If anybody could help me out I'd be
very grateful.

I have a report based on a complicated join of SQL views which is in turn
based on union joins. I do not really want to complicate it further. In my
report I group items under a commom value. In the Group Header I sum total
the values of a particular column which is being shown in the detail
section. The lookahead property for the totllaed item has been set True.

I need to calculate a percentage for each detail item's value against the
sum total of that colum for the group. This results in some very strange
results and more often than not there seems to be a sychronisation problem
at the time of calculation.

Is there a quick and dirty (and preferably effective!) way of achieving
this? I have a deadline of Friday this week to come up with the goods so
there's only one day to play with this and I've already wasted good time
trying variables, local variables; and of course the more I play with it the
further away from my target I seem to get! :=(

Any help really appreciated.

Thanks - David

Comments

  • edited April 2003
    To follow up with some more detail. If I use an SQL query (using Northwind
    here) such as:

    Select A.*,
    (select sum(B.ExtendedPrice) from [Order Details Extended] B
    where B.OrderID = A.OrderID) as OrderTotal
    from [Order Details Extended] A
    order by A.OrderID

    Then I can make use of the OrderTotal on each detail line but as I mentioned
    before the SQL Joins and Unions make it more than complicated and I want to
    have the flexibility to be able to format the report in any way I require
    using the same data.

    cheers - David

  • edited April 2003
    David,

    When trying to calculate a value based on the total, the report needs to be
    set to TwoPass, meaning it calculates twice. You can then use each pass
    event to calculate the percentage of the total as you need. Below is a link
    to an example showing how to do this.

    http://www.digital-metaphors.com/tips/PercentageOfGroupTotal.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2003
    Nico - many, many thanks for a simple but very elegant solution! I've
    applied the method to the current project reports and there are smiles all
    round - another notch for DR/RBuilder and Delphi :=)

    Thanks for your kind attention in this and other matters -

    best, David

This discussion has been closed.