Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Complex Formula help.. Post Reply Post New Topic
Author Message
crazycat503
Newbie
Newbie


Joined: 26 Dec 2012
Online Status: Offline
Posts: 2
Quote crazycat503 Replybullet Topic: Complex Formula help..
    Posted: 26 Dec 2012 at 11:15pm
Hi,

I need this kind of report...

101 UNAIDS 10 10
ER 2 8
ET 4 4

102 WHO 10 14
ER 4 10
ET 2 8


What happens is UNAIDS first gave 10 items. The donation is identified by 101 (incominginovoiceid). THe next 10 is the balance. Since it was the first donation, the balance is the same.

Then from those 10 items given, ER took 2 items. So we have 8 in store. Then ET took 4 from the 8 items. So, we have 4 in store.

Then WHO gave 10 items. Now since we had 4 items in store already [the 4 left from UNAIDS], the balance is 14. Now from the 14, ER took 4 so we remain with 10. FRom this 10, ET took 2 so we end up with 8.

I have used group headers to group them as in the above and it looks great. My approach was to create a forumula that would sum up total items taken in single batch first (i.e. 4 +2=6 for first, then again 4+2=6 for second), subtract from balance of that specific batch. So, the formula gave 6 for first batch which is correct. While for the second one it gave 6 as well which is wrong. It gave 6 because the balance is 10, not 14.

NOw, back to my question, how can i pass the remaining items from previous batch to the batch that is following? I.E. the 6 items of UNAIDS to the 10 newly WHO-donated items?

here is the method i tried but failed...


SHARED numberVar looper=0;

SHARED numberVar totalTaken;

SHARED numberVar pretotalTaken;

SHARED numberVar activein;

GLOBAL numberVar prein=0;

SHARED stringVar k;



WhilePrintingRecords;

if recordnumber=1 then
(

activein:={DSSMP_RPT_StockItem;1.incominginvoiceid};

prein:=0;

totalTaken:={@remainItems};
 //@remainITems is the formula that calculates total remaining items 
ToText({DSSMP_RPT_StockItem;1.originaltotal});

 //first record. so the balance is same as the exact no of items donated
)

else (
 //row contined.
if prein<>activein then (
 //if dealing with different donation
prein:=activein;

ToText({@remainItems} + {DSSMP_RPT_StockItem;1.originaltotal});


//originaltotal is the total donated for that specific donation
)




)



i kno it is a lot to ask but can u give me some insight on how to do this.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Dec 2012 at 11:08am
why not something like:
in header line:
shared numbervar balance;
balance := balance + {table.amountGiven};
 
in the detail used lines:
shared numbervar balance;
balance := balance - {table.amountUsed};
 
the balance will always be available and you will in effect get a running total.
 
HTH
IP IP Logged
crazycat503
Newbie
Newbie


Joined: 26 Dec 2012
Online Status: Offline
Posts: 2
Quote crazycat503 Replybullet Posted: 28 Dec 2012 at 11:21pm
hey lovkwelle,

thanks for your reply. will give it a shot then get back to 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.016 seconds.