I have created a crystal report in CR9 that shows all live orders.
Each live order has several operations associated with it and each of those have a status (basically if it is null it is incomplete, if it is 9 then it is complete).
So for example:
Order 1 - 200 - Pieces of Steel
Op 1 Issue Bar (null)
Op 2 Cut bar 9
Op 3 Deburr Bar (null)
Basically what I want to do is put the last completed operation on the same line as the order. So in the above instance, the last completed operation is Op 2 (cut bar) because it is the latest operation number that contains a 9.
I've set it up so the order number is the group and the details are the operations.
I've looked at using Maximum() by group but I don't know how to do a maximum where a condition is true statement. The maximum just returns the latest one alphabetically anyway and I need it in relation to the op number.
I've also tried suppressing the results but I don't know how to just report on the suppressed results.
I can't use select expert to just display operations where status = 9 because there are some jobs that don't have any completed operations and these need to appear on the report too.
assuming op number is always in the format of Op # Create this formula in detail section then use Maximum() summary on this formula in group header. You can delete this formula from detail
numbervar a := tonumber(split({table.op#}," ")[2]);
numbervar b;
stringvar output;
if {table.finished} = 9 and a > b then
(b:= a;
output := {table.op#} & " " & {table.op_description}
);
output
Thanks very much for taking the time to respond and suggest answers. CoSpringsGuy yours pointed me in the right direction.
I simplified it by just displaying the op number & " " & description if the status of the op was 9, else "". Then I just did a maximum() on the formula.
I think I must've had brain freeze or something prior to posting :)
Thanks again.
David.
Related
I have searched on other questions similar to this but none seem to be in the same situation.
I have a series of transactions in which I am using a running total named TranNumber which resets on the change of the account number. When I sort by descending transaction date this running total gives me the most recent transaction as 1.
I also have another formula which contains a list of transaction codes and their position on a workflow (done using a select case formula).
I have tried to sum the following formula as well as variations such as using variables and passing data into a sub report and back to 'trick' the software into not seeing it as a running total, still to no avail as I can then not sum a variable.
if {#TranNumber} = 1 then
if {#ProcCode} startswith "1 - " then 1 else 0
Ultimately I want a count of accounts in each position on the workflow to then put into a graphical form.
If anyone has tried to do this successfully or can suggest a way to only bring back the most recent transactions for each account to avoid having to use the above method it would be greatly appreciated :)
Thanks in Advance
Resolved this issue by using the formula above and assigning to a variable and placing a counter formula in the details which worked like the below
shared numbervar x;
If {#TranNumber} = 1 then
if {#ProcCode} startswith "1 - " then x := x + 1
I then placed this formula in the details and then simply output the variable in the report footer which gave me the number I was looking for.
I have a report that will occasionally have more than one detail record in a group. In such a case I only want to display the last in the sequence. I have a sequence number associated with each record so I need to suppress all detail rows in the group other than the one with the maximum sequence number.
I've tried using a global variable to recalculate the max value as of each detail record but I haven't been able to write a formula that, while printing, can use this maximum sequence number to suppress the row if it does not contain a value equal to the max sequence number.
From what i understand you have data organized by this:
Data1 Data2 SeQuencenumber
1 a 1
2 b 1
2 c 2
2 d 3
And from what i understand your want your output look like (group by Data1):
Data1 Data2 SeQuencenumber
1 a 1
2 d 3
To do so you need to write formula in detail section which compares your current detail sequence number and count of all for that group (Data1). Right-click your detail section and write formula here
Formula looks like :
if {SequenceNumber} = count ({SequenceNumber},{Data1}) then true
else false
Hope it helps, if you have any further questions feel free to ask.
try like this:
Shared Stringvar array concatenate;
concatenate:=concatenate+CStr(Sequencenumber);
now in suppress condition of details:
Shared Stringvar array concatenate;
if Maximum(concatenate)=Sequencenumber
Then false
else true
I had tried a solution similar to the one from KuKeC but with the maximum function instead of count. But while reviewing the KuKeC solution I finally saw that I was already suppressing the detail band when a date in the detail did not match a parameter date, yet the maximum function was giving the max of all data whether displayed or not.
So I first needed to add a formula field that would return the sequence number only if the data date matched the parameter date
if {PSLRegister.PSLRPPStartDate} = {?PP_Start_Date} then
{PSLRegister.PSLRSeqNo}
else
0
then I used this formula field in the equation to suppress the detail record
Maximum({#SeqIfDateMatch}, {TrnsltEmployee.TSEmployeeID}) <> {PSLRegister.PSLRSeqNo}
Thanks to all
I'm very new to crystal reports and my code issue isn't to complex, but I'm struggling find the right structure.
I have jobID's that all start with the same first 5 digits if they come from the same SalesOrderID. the five digits they start with are the salesID number.
I want to display all of the JobIDs under a SalesOrderID if the production is complete on just one of them.
if {Jobs.jmpProductionComplete} =-1.00
then
(
If {Jobs.jmpJobID} startswith left({Jobs.jmpJobID},5)
then {Jobs.jmpJobID}
else ""
)
but that produced a error saying "The result of selection formula must be a boolean"
Next I tried:
if {Jobs.jmpProductionComplete} =-1.00 then
(
If {Jobs.jmpJobID} startswith left({Jobs.jmpJobID},5)
then not(isnull({Jobs.jmpJobID}))
)
But that only displayed the single JobID that has been marked Production Complete.
Next I tried:
Created a formula with this code:
left({Jobs.jmpJobID},5)
named it #jobidformula
Go to the Group Expert > Move this formula to the Group List
Suppressed the Group Header and footer
Go to Report > Selection Formulas > Group and used this code:
Minimum({Jobs.jmpProductionComplete}, {#jobidformula}) = -1
still didn't work. Any other pointers anyone can give me?
I figured it out!
I first made it so that my report only shows the JobIDs which production is complete grouped by salesOrderID
I made a subreport where the parameter was SalesOrderID
in the selection formulas I set it so that Production was not complete.
I lined them all up and vooila! It works without issue.
I have a rather simple problem that I haven't managed to workout for myself despite many hours of searching the web.
I have a report containing timestamped data from a few thousand devices (loggers), to present the data in a sensible manner, I set up two groups in the report; Loggers and Timestamp so the data first grouped by logger id and then by timestamp which is working fine
Group 1 Logger 1
Group 2 Timestamp 01/08/2012
Data...
Data...
Data...
Group 2 Timestamp 02/08/2012
Data...
Data...
Group 1 Logger 2
Group 2 Timestamp 01/08/2012
Data...
Data...
Data...
Now the data (detail) fields are hidden from the user and I only want to display the header for group-2 if there are 4 or more records in each group-2. To achieve this I have used the following suppression formula on group-2
Count ({GMAC_spDg2Report;1.tTimeStamp}, {GMAC_spDg2Report;1.tTimeStamp}, "daily") < 4
The trick is that there are certain level 1 groups where all group-2 headers are suppressed and where this is the case, I want to hide the group-1 header as well.
Using the same suppression formula as group-2 in group 1 did not yield the desired result. I have also tried to use a running total (called {#Count Unsupressed Days}) in the group-1 footer with a distinct count and the formula below being reset on each group-1
Count ({GMAC_spDg2Report;1.strLogger}, {GMAC_spDg2Report;1.tTimeStamp}, "daily") > 4
The running total works perfectly, returning a 1 in group-1 footer if the group has sub groups that are not suppressed and 0 if all group-2 headers are suppressed.
So here is the CHALLENGE, I cannot seem to apply a suppression rule in the header of group-1 using the output from the running total.
To demonstrate the problem I created a formula field containing only the output from the running total and placed this in the group-1 header.
The results are confusing to say the least... the formula field does not show the same value as the running total and hence the suppression rule is not working.
I hope this makes some kind of sense... I feel like I have tried everything
I don't have a definite solution, but using a formula field starting with
WhilePrintingRecords;
...
the formula will be processed after all records are read, and therefore you will be able to use it in section headers with correct result.
Now there is the problem of finding a formula logic that will be of use for you, but perhaps this first step can help you in the right direction.
I had a similar problem once. As I remember, the trick was to check Suppress blank section in every detail section and checking some similar sounding option Suppress blank group (?) in group header section.
Sorry I can't give you the exact name, it's long ago and I used the German version. I know it's possible without formulas, though.
I take it you don't use sub reports. If you do, note that the trick only works if the sub report has the option Suppress empty report (?) checked along with what I wrote above.
Using VS 2008 Crystal Reports, I would like to do a running total on a formula that is calculated on a group change. When I click on add a running total, this formula does not appear in the Available Tables and Fields list.
This is the logic:
On Change Group of group
if CalculatedValue > 0 then
ReportRunningTotal1 += CalculatedValue
else
ReportRunningTotal2 += CalculatedValue
Can I specify a condition in a running total? If not, how else could I do this?
More info: I am doing a running total called GroupRunningTotal of the value of db field BillableHours. At change of group, I am comparing GroupRunningTotal to a db field for that group MaxHours, and I display a result of MaxHours - GroupRunningTotal at the group level.
Appropriate today - Think of it like the electoral college - the person who wins the election does not depend on total number of votes, but of number of votes in the electoral college.
I'm interpreting your question to mean that you want to add up all the negative values in one running total (RT_Neg) and all the positive values in another (RT_Pos). How about this:
Make the RT_Neg running total. Under Field to Summarize, sum your {Tbl1}.{Amount}. Under evaluate, enter "{Tbl1}.{Amount}<0" as your custom formula. Never reset.
Make the RT_Pos running total. Under Field to Summarize, sum your {Tbl1}.{Amount}. Under evaluate, enter "{Tbl1}.{Amount}>0" as your custom formula. Never reset.
Insert both running totals in the group footer (if you put them in the header, it may not sum properly)
Alternatively, you can:
Make a custom formula "If {Tbl1}.{Amount}<0 then {Tbl1}.{Amount} else 0" and make a running total based off that.
I think one of these 2 options will get you to your goal.
You most likely cannot use one RT field as condition for other RT field. You can use formulas, placed on group footer and evaluated 'whileprintingrecords()'; in these formulas you can assign/sum into some variables and display these variables at the end of report. About like next (generic idea only, you need initialization and display routines as well):
numbervar rtcurrent := sum({somefield}, {groupfield});
numbervar rtplus;
numbervar rtminus;
if (rtcurrent > 0)
then rtplus := rtplus + rtcurrent
else rtminus := rtminus + rtcurrent;