Print Page | Close Window

virtual groups

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=252
Printed Date: 03 May 2025 at 12:12am


Topic: virtual groups
Posted By: TokyoAnt
Subject: virtual groups
Date Posted: 27 Feb 2007 at 6:39pm
Hi,
 
I have a single group that has various names which serve as subgroups, though they are really not subgroups in the report, just differerent names.
(make sense?Confused)
 
For example, the group includes: "Infrastructure Services", "IS-Team", "IS-PAT". The rows starting with IS serve as subgroups to Infra~ Services, even though they are in reality equal elements of the same group.
 
How can I sum these as below:
 
 
 
 
if GroupName ({ResourceUsageReport.OrganizationName}) = "Infrastructure Services"
then
    // sum group above that begins with "IS"
 
else if GroupName ({ResourceUsageReport.OrganizationName}) = "Managed Services"
then
     // sum group above that begins with "MS"
else if GroupName ({ResourceUsageReport.OrganizationName}) = "Management Consulting"
then
    //  sum group above that begins with "MC"

else
    // sum
 
 
Hope this makes sense. Thanks very much for any ideas on this.
 
Ant
 



Replies:
Posted By: BrianBischof
Date Posted: 27 Feb 2007 at 7:47pm
I would create a global variable for each group sum you want to track. Then insert these variables into the proper place in the formula you listed above.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: TokyoAnt
Date Posted: 27 Feb 2007 at 8:49pm
Thanks for your answer. I'm still unsure as to how what I would use to create the values for the global variables with.
 
I need to somehow determine which 'group' i.e the organizationName & its associated value I will be summing. By looking at the code I pasted, can you see how this could be done?
 
Basically what I want to do in "very" pseudo code is:
 
 
if GroupName ({ResourceUsageReport.OrganizationName}) = "Infrastructure Services"
then
sum ({ResourceUsageReport.OrganizationName})  only those who's Len(({ResourceUsageReport.OrganizationName}),2) = "IS"
 
else
 
 
if GroupName ({ResourceUsageReport.OrganizationName}) = "Managed Services"
then
sum ({ResourceUsageReport.OrganizationName})  only those who's Len(({ResourceUsageReport.OrganizationName}),2) = "MS"
 
 
Basically, I don't have a clue how to do thisConfused
 
Thanks for any ideas on this
 
Ant


Posted By: BrianBischof
Date Posted: 27 Feb 2007 at 10:21pm
Ok, I don't have time to write the report, but here is some more pseudo-code that should get you in the right direction.


Global NumberVar ISSum
Global NumberVar MSSum
if GroupName ({ResourceUsageReport.OrganizationName}) = "Infrastructure Services" and Len(({ResourceUsageReport.OrganizationName}),2) = "IS"
then
ISSum = ISSum + {ResourceUsageReport.OrganizationName}
else
if GroupName ({ResourceUsageReport.OrganizationName}) = "Managed Services" and Len(({ResourceUsageReport.OrganizationName}),2) = "MS" then
MSSum = MSSum + {ResourceUsageReport.OrganizationName}

Hmm.. for some reason the spacing is all screwed up, but its readable.


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: TokyoAnt
Date Posted: 01 Mar 2007 at 8:07pm
Hi Brian, Thanks for the input. I'm an absolute beginner to reports & there must be something fundamental about reports & perhaps their evaluation time that I'm missing.
 
What I need is to sum all the rows (they are average values) with group names starting with IS & place this value in the row with the  group name "Infrastructure Services". etc.
I tried applying what you recommended above but all group rows returned a value of 0.
 
Below is the code. (I assumed you meant Left when you used Len in your example):
 
Global NumberVar ISSum1;
Global NumberVar MSSum1;
Global NumberVar MCSum1;
 
 
// For the groupheader valued "Infrastructure"

if GroupName ({ResourceUsageReport.OrganizationName}) = "Infrastructure Services"
then 
 
// Sum all group headers that start with "IS"

    if Left(({ResourceUsageReport.OrganizationName}),2) = "IS"
    then
        ISSum1 := ISSum1  + ( Sum ({ResourceUsageReport.Period1}, {ResourceUsageReport.OrganizationName})
        / sum( mailto:%7b@AvailWkHrs1%7d,%7bResourceUsageReport.OrganizationName%7d%29*100 - {@AvailWkHrs1},{ResourceUsageReport.OrganizationName})*100 )
   
 
for the groupheader valued "Manged Services"

else if GroupName ({ResourceUsageReport.OrganizationName}) = "Managed Services"
then
 
// Sum all groupheaders that start with value  "MS"

    if Left(({ResourceUsageReport.OrganizationName}),2) = "MS"
    then
        MSSum1 := MSSum1 + (Sum ({ResourceUsageReport.Period1}, {ResourceUsageReport.OrganizationName})
 
// All groups starting with IS, MS etc (i.e. Not named  "Infratructure Services" or "Managed Services")

else
    Sum ({ResourceUsageReport.Period1}, {ResourceUsageReport.OrganizationName})
    / sum( mailto:%7b@AvailWkHrs1%7d,%7bResourceUsageReport.OrganizationName%7d%29*100 - {@AvailWkHrs1},{ResourceUsageReport.OrganizationName})*100
 
 
* Currently I'm just summing them for test purposes. They will need to be averages but this is not an issue so disregard that. I'm just after *placement* of values at the moment.
 
Thank you very much for any assistance you can give on this.
 
Regards
 
Ant
 




Print Page | Close Window