Print Page | Close Window

Percentage of a Group IF.

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=23037
Printed Date: 14 May 2024 at 5:49pm


Topic: Percentage of a Group IF.
Posted By: mikevtss
Subject: Percentage of a Group IF.
Date Posted: 09 May 2023 at 12:24pm
Hi all

Im trying to work out how I what a percent of a total is of the group.

623458 <- grouped     Total
623458   Cable 1mm     12
623458   Cable 2mm     0
623458   Cable 4mm     4
623458   Cable 7mm     0
623458   Cable 10mm    5

I need to total up the items that are 0 and display it as a percentage of that group. In this case it would be 40%.



not sure how to go about it.



Replies:
Posted By: lockwelle
Date Posted: 07 Sep 2023 at 12:03pm
shared variables would work...

Way too late I fear.
The basic idea is to reset the counters when the grouping changes...it looks like when 623458 changes.

The increment part would be in the details section and would be something like:

shared totCount := totCount + 1;
shared zeroCount;
if {field} = 0 then zeroCount := zeroCount + 1;

HTH



Print Page | Close Window