Solved

Formula for Summary Across Hierarchy

Posted on 2004-08-16
9
1,105 Views
Last Modified: 2008-02-01
I am working on a report that uses group by hierarchy feature. I can get summaries for two columns at different levels by ticking 'summary across hierarchy' box. But I can't do calculations over the summarized fields.(summary across hierarchy) using formula.

In fact, if I don't tick 'summary across hierarchy' box, the summary value will not show up in preview as well.  Also I notice, when I was editing
the formula, I click on the summary field available( this was generated by inserting summary and tick 'summary across hierarchy') , it shows
the following:
  Sum ({Tablename.ColumnA},{Talbename.Employee_ID})
If I just use this as content of the formula, it will also not show anything when previewing it.

This doesn't happen to normal grouping. I guess Crystal is doing something special to  'summary across hierarchy'

 I would like to know how to use formula or function to get these values so that I could do further calculations.

Thanks in advance for your help.
0
Comment
Question by:nancen
  • 4
  • 3
9 Comments
 
LVL 10

Expert Comment

by:ebolek
ID: 11825677
what kind of calculations do you want  to do. If you explain your report and what you need to accomplish, maybe I can help you .

Regards
Emre
0
 

Author Comment

by:nancen
ID: 11836848
Thanks Emre, my report  is like this:

              office  ID         num of shift            task scheduled      %  shift per task
                                    formula1                formula2                formula3

Here I use hierarchygroup ,  group by office_ID, parent_id is parent_office_id,  hopefully will get the look as follows:
              Corp               98
 
0
 

Author Comment

by:nancen
ID: 11836984
Sorry Emre,  please forget preious comment,  I just press the space bar, it appeared like this :(

my report  is like this:

              office  ID         num of shift            task scheduled      %  shift per task
                                    formula1                formula2                formula3

Here I use hierarchygroup ,  group by office_ID, parent_id is parent_office_id,  hopefully will get the look as follows:
              Corp               98                          100                       98%
                     Dep1        50                          50                         100%
                          off1    30                           40                         75%
                          off2    20                           10                         200%
                     Dep2        48                           50                        96%
                           off3    48                           50                        96%
Notice, an office could have possible sub_office. Database table only provide office level Data, not Department and Corporate level. These
have to be calculated.

I can get the Department level and corporate level summary for  shift and task. as following:

    office  ID         num of shift            task scheduled      %  shift per task
                          shift sum                    task    sum                    

Here sum means summary across Hierarchy.

But I got problem to calculate this field  "%  shift per task"  using a formula like:
Sum({shift}, {office_id}) % Sum({task},{office_id})

It doesn't complain, but just doesn't show up in the preview.

I know I could calculate these values in sql using sql command  "start with, connect by" kind of thing. I think that is not efficient, and can't coupe with complex situtation. Anyway, I just want to do a simple calculation which two numbers already showed up in the report.

Thanks again for your help and best regards.

Nan
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 10

Expert Comment

by:ebolek
ID: 11840925
Do the same thing but where you inserted
Sum({shift}, {office_id}) % Sum({task},{office_id})
insert  a new section, and put this  formula there. I think crystal has a problem witht he evaluation time and cant display your formula. Your summary calculations have to be done for your formula to be evaluated.
You can also use

Evaluate after(summary) function. That will make sure that your formula gets evaluated afer the summary function takes place
0
 

Author Comment

by:nancen
ID: 11848750
Thanks a lot ebolek.  

I have tried the solution you proposed, unforunately both are not work.

I think the main problem is how to  use a formula to do summary across hierarchy. Simple illustration is how do I say:
Evaluate after(summary across hierarchy)  ?

If I just put Sum({shift}, {office_id}) in the report, it will not show up. Although this is generated by "Insert--> Summary", then choose
field to summary, as well as the group. Then I  tick the 'summary across hierarchy' box.

Note, If I not using formula, it will show the summary across hierarchy correctly if I tick the  'summary across hierarchy' box'. However,
if I don't tick the magic box, it will also not show up.

That's why I assume crystal doing special thing with 'summary across hierarchy'. Because there is no difference in terms of formula. But
the result is different.

I probably have to use function. That is write a special summary function. However, I even don't have a single clue to write a function to
do same thing as crystal  summary function does, for I don't know which construct holds database values, as well as group information,
etc.

Thanks and Best Regards.

Nan
0
 
LVL 10

Expert Comment

by:ebolek
ID: 11850960
where are you going to write that function
0
 

Author Comment

by:nancen
ID: 11858107
Hi ebolek,

I couldn't remember exactly where, for I didn't have crystal at home. But I am sure
you can add a user defined function in the Crystal Report, and I did tried once. Once the function is written, I could then use the function in the formula.

I already got an idea to solve the problem. Unfortunately I couldn't test it out now,  Basically it will be like this:

NumberVar sum;
IF OnFirstRecord then
    sum :=0
ELSE IF Previous({Office_type}) = {Office_type} then
    sum := sum + {shift}

I have to initialize  sum in the report header. I also have to add a column in the
table to specify office type.

Thanks  again for all the help.

Nan
 
 
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12108402
PAQed, with points refunded (100)

Computer101
E-E Admin
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question