Print Page | Close Window

Previous Value

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14551
Printed Date: 02 May 2024 at 1:26pm


Topic: Previous Value
Posted By: CoachGBT
Subject: Previous Value
Date Posted: 30 Sep 2011 at 6:12am
I'm trying to calculate previous value when I attempt to get the value, I get the message; "This field has no previous or next value". That is correct, but I'm trying to determine the value.
 
Any suggestions would be greatly appreciated.
 
Thanks,
CoachGBT



Replies:
Posted By: DBlank
Date Posted: 30 Sep 2011 at 7:03am
What exactly are you checking?


Posted By: CoachGBT
Date Posted: 30 Sep 2011 at 8:13am
I'm trying to get a monthly calculation of number of action items with a status of OPEN and a status of RELEASED. So my calculations would be something similar to
 
Previous Month Total + OPEN Status - RELEASE Status = BACKLOG or End of Month Total.
 
Now Previous Month Total doesn't have a starting value, but I intend to use End of Year total as my Previous Month Total (Dec 2011) value to carry over for the start of 2011 (Jan).


Posted By: CoachGBT
Date Posted: 04 Oct 2011 at 4:25am

This is what I accomplished so far;

IF GROUPNAME ( mailto:%7b@NEW_DATE - {@NEW_DATE }, "MONTHLY") = 'JAN' THEN
145 + (SUM ( mailto:%7b@CREATED - {@CREATED CT}, mailto:%7b@NEW_DATE - {@NEW_DATE }, "MONTHLY") - SUM ( mailto:%7b@RELEASED - {@RELEASED CT}, mailto:%7b@NEW_DATE - {@NEW_DATE }, "MONTHLY"))
 
FYI:
Total Prior to JAN-11  =  145
         Jan Created CT =  137
       Jan Released CT =  115 
    Jan Backlog Count =  167
 
From here I would like to pass the Backlog Count to the following months (Feb - Oct), but I get a 0 for my Backlog Count for (Feb - Oct). This is what I've tried to get on-going Backlog Count:
 
IF mailto:%7b@MONTH - {@MONTH } = 'JAN' THEN 0 ELSE
  mailto:%7b@BACKLOG - {@BACKLOG } + Sum ( mailto:%7b@CREATED - {@CREATED CT}, mailto:%7b@NEW_DATE - {@NEW_DATE }, "monthly") - Sum ( mailto:%7b@RELEASED - {@RELEASED CT}, mailto:%7b@NEW_DATE - {@NEW_DATE }, "monthly")
 
Thanks,
CoachGBT


Posted By: DBlank
Date Posted: 04 Oct 2011 at 5:09am
Sorry Coach, lost track of your post...
Previous() is a function that is referencing exacly the row above a row, it is not in reference to anything else. So your "Previous Month Total" was asking for the value from a field called "month Total" from the previous row of data. That is a non-existent field hence the error you got.
I think I see what you are trying to do here but not being familiar with your data it is very difficult to tease out.
I am assuming you have several if then formulas here that make a 1 or 0 based on your conditions.
You can used shared variable formulas to do conditional adding or subtracting (passing a value to the next row/group) but i think I would do this a little differently (as I prefer Running Totals anyway). This is not answering your question directly because I think the path you are on is going to get too convoluted and I would restart down a different 'cleaner' path...
 
Create one RT for the Year start
name=yearstartamount
field to summarize=whateer field is your 145 value
type = sum
evaluate=use a formula
onfirstrecord
reset=never
//this gives you one constant value for the entire report
another RT
name=monthlycreated_reset
field to summarize= mailto:%7b@CREATED - {@CREATED CT}
type=sum
evaluate=for each record
reset=group ( mailto:%7b@NEW_DATE - {@NEW_DATE })
 
another RT
name=monthlycreated_NO_reset
field to summarize= mailto:%7b@CREATED - {@CREATED CT}
type=sum
evaluate=for each record
reset=never
 
another RT
name=monthlyReleased_reset
field to summarize= mailto:summarize=%7b@RELEASED - {@RELEASED CT}
type=sum
evaluate=for each record
reset=group ( mailto:%7b@NEW_DATE - {@NEW_DATE })
 
another RT
name=monthlyReleased__NO_reset
field to summarize= mailto:summarize=%7b@RELEASED - {@RELEASED CT}
type=sum
evaluate=for each record
reset=never
 
Total Prior to JAN-11  =  145   (show #yearstartamount on first
         Jan Created CT =  137   (#monthlycreated_reset)
       Jan Released CT =  115    (#monthlyReleased_reset)
    Jan Backlog Count =  167   (formula field as:
#yearstartamount on first + #monthlycreated_NO_reset - #monthlyReleased_NO_reset


Posted By: CoachGBT
Date Posted: 04 Oct 2011 at 6:51am
I get what direction you have me going, but I'm stumped with the on-going Backlog Count (Feb - Oct)
 
From here I would like to pass the Backlog Count to the following months (Feb - Oct), but I get a 0 for my Backlog Count for (Feb - Oct). This is what I've tried to get on-going Backlog Count:
 
IF mailto:%7b@MONTH - {@MONTH } = 'JAN' THEN 1 ELSE
  mailto:%7b@BACKLOG - {@BACKLOG } + #monthlycreated_NO_reset - #monthlyReleased_NO_reset
 
I'm still getting 0 for (Feb - Oct) Backlog Count.  I tried passing the value from this formula :
#yearstartamount on first + #monthlycreated_NO_reset - #monthlyReleased_NO_reset
 
to a new formula name BACKLOG.
 
Thanks,
CoachGBT


Posted By: DBlank
Date Posted: 04 Oct 2011 at 7:07am

A few trouble shooting suggestions.

1 place each individual RT on the detail lines and scrutinize each one per row and group footer to make sure it is doing what you want/expect. My initial guess is that for each of the "NO_reset" RTs you accidently have then reseting on each group.
Let me know what you find when you look ata each RT.


Posted By: CoachGBT
Date Posted: 04 Oct 2011 at 7:57am
Got It! Oversight on my part.
 
Greatly Appreciated!


Posted By: CoachGBT
Date Posted: 06 Oct 2011 at 2:51am
Thanks for all your help.
 
I have a question about Cross-Tab:
I have a Formula (the formula has RT Fields) and I want to add the Formula to Cross-Tab as a Summarized Field. When I open the Cross-Tab Expert, the Formula I want to add doesn't appear in the list of Report Fields to choose from.
 
So far the Cross-Tab has eleven columns,  months (Jan - Oct) and Total, and two rows this is all fine and well. My two rows are:
Created CT
Released CT
I want to add a third row:
Backlog CT (And for Backlog CT I want to use the Formula that has RT Fields). This is the formula:
{#yearstartamount on first} + {#monthlycreated_NO_reset} - {#monthlyReleased_NO_reset}
 
Thanks Again,
CoachGBT




Posted By: DBlank
Date Posted: 06 Oct 2011 at 4:39am
I think that an RT itself can sometimes be added to a crosstab however they act more like whileprintingrecord formulas which get created in a later data pass. I think sometimes the design/grouping of the crosstab can make a RT ineffective if it does not match the group structure of the report (that defines how the RTs are created).
My inital guess is the {#yearstartamount on first} is making it not available in the CT.
You might have to resort to mimicking a CT in the report footer if it is critial for your report.



Print Page | Close Window