Crystal Reports 2011: Calculate the number of times a value occures and the number of days in between - crystal-reports

It occurs to me that I might have been able to find the answer to this but so far i've come up short. Also, I am pretty new to Crystal Reports (2011) so please forgive my ignorance if this is something I've missed. Here's the issue:
I have a report where I am pulling the number of times a value happens for a specific target, specifically how many times a specific procedure happens for a person within a specified date range. I have the results grouped by person.
I show the person, the procedure code and the date the procedure happend within that group.
What I NEED to do now, is to figure out how to return some type of visual indicator that there is at least 3 days in between each procedure for each person.. example..
[GROUP #1 NAME]....................[PROC_CODE]......[PROC_DATE]
[{Last_Name}, {First_Name}].....PROCEDURE..........PROCEDURE DATE
(Please forgive the "....." as I was trying to space out the headers and results)
Having said all that, the "Procedure Date" I would like to show up in RED if the next result within the group (by person) falls within 3 or less days from the last date. I am really hoping this makes sense to someone. Thank you in advance for your help!

create a formula called "DateDiff": DateDiff("d", {Proc_Date}, previous({Proc_Date}))
then in your Section Expert, choose the group that your data is in. Click the color tab. Choose the "x-2" formula button and enter: if {#DateDiff} > 3 then crred else crnocolor
edit so your next group doesnt pick up the last value:
if ({group1_field} = previous({group1_field})) then
if {#DateDiff} > 3 then crred else crnocolor
else
crnocolor

Related

Crystal Report - Show row only when certain codes present

hoping someone is able to assist me. Been trying to figure this out for months.
I'm working on a meal report. The report currently shows peoples mid meals: morning tea, afternoon tea and supper.
I'm trying to have the report show breakfast, lunch and dinner as well, but only if there is a mid meal present. So exclude or suppress when its only breakfast lunch and dinner, but show if its breakfast and supper for example.
My issue is from the database table the 6 meal times are all the same database field so I can't figure out a way to have the functionality I want. I can only show all breakfast, lunch, dinner or show none.
Is there a formula or something else I can use to achieve this.
Thanks in advance.
Assuming you are grouping the report on Customer, create a formula that returns 1 for mid-meal and zero otherwise.
Then, create a Group selection formula that requires the SUM of that formula at the Customer level to be more than zero.
The Group Selection formula would be something like:
Sum({#TheIfFormula},{YourGroupByField}) > 0

How can I use Crystal Reports record selection to choose from a list AND included a specific field

I am trying to figure out how to write a formula in the record selector that would allow me to select records in a specified list....but ONLY if there is also a specific record.
In My example. I am pulling earnings codes for employees from specific payroll transactions. For each Transaction date...each employee will have up to 10 codes.
I have my record selection set as this to narrow down the codes I want to see:
{UPCHKD.EARNDED} in ["01", "02", "BNSQT", "BVMT", "CASHBO", "FLAT", "HOL", "HOLPAY", "WAPFML"]
The issue is that I only want to see the first 8 codes IF there is also the WAPFML code. I can't figure out how to tell the record Selector to pick records that have BOTH WAPFML and any of those other 8 codes.
{UPCHKD.EARNDED} in ["01", "02","BNSQT", "BVMT", "CASHBO", "FLAT", "HOL", "HOLPAY", "WAPFML"] and
{UPCHKH.TRANSDATE} in {?Beginning Check Date} to {?Ending Check Date}
I hoped to see only checks where the WAPFML code existed. But I'm obviously returning checks that may not have that code. Using Group selection doesn't work as then I don't see the lines for the other codes.
Assuming you are grouping on {Employee_ID}, Add a group selection formula of MAX({UPCHKD.EARNDED}, {Employee_ID} ) = "WAPFML"
This takes advantage of the fact that "WAPFML" happens to be the largest alpha value in the set. If that is not the case, a more robust approach is to add the UPCHKD table a second time (with an alias), join on same Emp_ID to the first alias, and add a record selection condition on the 2nd alias forcing it to be "WAPFML"
OH I GOT IT! I was grouping by Employee and then transaction date. I entered Maximum ({UPCHKD.EARNDED}, {UPCHKH.TRANSDATE}) = "WAPFML" and took maximum of each transaction date and BOOM. Which now makes all the sense in the world. Thanks so much MilletSoftware for helping me!

Create a warning prompt box that appears before parameters are set in Crystal Reports

I have created a Crystal Report for some of my users with a date range parameter set. The volume of information that the SQL command returns means that anything over a 7 day period in the date parameter slows the report to unusable speeds and subsequently locks the DB for all other users.
Does anyone know of a way to create a prompt in Crystal Reports that will appear before the parameter set? I.e. As soon as they select the report and click "Open", the first thing they see is a box saying "Please ensure a maximum 7 day date period". Then upon clicking "OK" or something of my choosing, they are presented with the parameter fields and can continue with the report.
If this cannot be done, is there a way to restrict the parameters so that when the users select the start date, they can only select a maximum of 7 days after.
The other option, if it is doable, is to have them select the start date and then it auto complete the end date with a date 7 days after the start date.
At the moment i have just added (Must be a 7 day period) to the parameter title but i dont feel this does a good enough job at advertising it and as soon as i publish it i know someone will want to get 4/5 years worth of data...our clinicians will be most unimpressed if they PAS system locks up during a busy clinic.
I have attached a screenshot of the kind of thing i am after. It is a little crude as it was done in paint but it gets the point across.
I have searched high and low for this solution so i am not sure it even exists, but am asking out of sheer desperation.
Thanks in advance,
Mike
If you use Crystal Report solely (not within a program like .Net app) you can select your latest proposition. Get start date and in your SQL command (View, Stored Procedure, ...) select items from startDate to startDate + 7 days.
Depending on your DBMS there are ways to add some value to date (like dateadd function in MSSQL).
So its done.

How to filter crystal report so that if one JobID is ProductionComplete that all other jobID with the same first 5 digits will also be displayed

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.

Backward looking back log report

I'm trying to write a backlog report in Crystal Reports XI attached to Fluke Met/Track database (Sybase back-end)
I have it running between a start & end date, then grouped by Month and then Day.
I need it to show all of the units that were in the lab on the days between the start & end dates
October Units
2
22525
22526
3
22525
22526
22527
4
22526
22527
22530
The order of the units doesn't matter, just that the units are showing up.
Maybe I'm just having a rough day, but I'm not seeing how this can be accomplished.
You can accomplish this by adding a group for your date, opening up the Group Expert, click your Group click Options, then you should see something along the lines of "The section will be printed:" and you can select: for each day.. This should allow grouping for each day.