Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Total Detail lines only after the n-th detail Post Reply Post New Topic
Author Message
its-a-wrap
Newbie
Newbie


Joined: 20 Nov 2017
Online Status: Offline
Posts: 3
Quote its-a-wrap Replybullet Topic: Total Detail lines only after the n-th detail
    Posted: 28 Nov 2017 at 9:00am
I cant figure out how to calculate the following. Total pcs of candy ignoring the first "n" rows.   

for example: n=2 so:

detail rows-----
row | name | pcs of candy
1     susan      5
2     ben        10
3     james      3
4     laura      1

REPORT FOOTER------
TOTAL PCS of Candy: 4


I have tried a number of things but all have given errors about run time calculations (or something similar).
IP IP Logged
Valert16
Groupie
Groupie
Avatar

Joined: 21 Mar 2016
Location: Spain
Online Status: Offline
Posts: 57
Quote Valert16 Replybullet Posted: 21 Dec 2017 at 11:29pm
Create a formula that replicates the column 'pcs of candy' but returns zero if the row is less than the Nth.
A posible formula could be (VB syntax):

WhileReadingRecords
Global Counter as Number
If Counter + 1 > NthRow Then
    formula = {pcs_of_candy}
Else
    formula = 0
End If
Counter = Counter + 1

Replace NthRow with your value and {pcs_of_candy} with the exact name of the field. Place the formula in detail section and hide it.
Create a Summary field and choose the formula you've created as a field to summarize. You should get the correct total.
IP IP Logged
its-a-wrap
Newbie
Newbie


Joined: 20 Nov 2017
Online Status: Offline
Posts: 3
Quote its-a-wrap Replybullet Posted: 10 Jan 2018 at 3:48am
Thank you. This is similar to what I had tried previous to asking the question. It's a very simple problem, so i was surprised my efforts did not work until now. For some reason the crystal syntax or maybe missing the "WhileReadingRecords" caused it to not work. In any case, I figure I would share my code.

The actual problem was to charge customers a 4% fee only after the tenth order they've placed.


/////////////////////////////

WhileReadingRecords;

//How many orders are free
Global numberVar freeOrders;
freeOrders := 10;

//Fee percentage
Global numberVar orderFeePercentage;
orderFeePercentage := .04;

//Count number of orders so far and iterate++
Global numberVar rowCounter;
rowCounter := rowCounter + 1;

IF rowCounter > freeOrders
THEN {@salesLessDiscountsLessMisc}*orderFeePercentage
ELSE 0
IP IP Logged
Valert16
Groupie
Groupie
Avatar

Joined: 21 Mar 2016
Location: Spain
Online Status: Offline
Posts: 57
Quote Valert16 Replybullet Posted: 10 Jan 2018 at 5:14am
I forgot to mention I use Basic syntax, not Crystal.
May this help you?
IP IP Logged
its-a-wrap
Newbie
Newbie


Joined: 20 Nov 2017
Online Status: Offline
Posts: 3
Quote its-a-wrap Replybullet Posted: 19 Jan 2018 at 3:19am
It was helpful. But, i did also post the crystal syntax above to help other users in the future. Thank you.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.017 seconds.