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

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!

Related

Crystal Report create separate report pages based on field value change

Looking for some advice related to data grouping and printing in Crystal Reports.
I'm working with an order confirmation form. Ideally I would create separate report pages based on a specific field value change for the 'warehouse' field. So, if any given line on an order comes from warehouse A, it prints together. Then we'd get a page break, and we'd see the form repeat for any lines coming from warehouse B.
I've inserted a new group for "warehouse" and configured the group as 'New Page Before.' But when I attempt to print I'm getting an error related to "There must be a group that matches this field". So there must be some pre-existing grouping that I'm not considering. I'm hopeful I can figure this out.
I am interested to get thoughts on overall design, and if the grouping approach I am trying to take is even the correct one.
Somewhere in your report you probably have a formula such as:
Sum({some_value}, {some_field})
where the {some_field} used to be -- but is no longer -- grouped upon.
Fix that expression to set the desired aggregation level (the 2nd argument) to a field you are actually grouping on.

Multiple copies of a record based on formula

Good afternoon,
I am very new to Crystal Reports, so am not sure where to look for this information and would appreciate if someone can point me in the right direction or tell me if what I am asking for is impossible.
One of our departments uses a field called RecordChanges to note changes made to a record. The field is text and the department stores information there about the date a change is made and the type of change, separated by commas (i know this is terribly inefficient, but it's what I have to work with). I have a Crystal Report that parses this text field and picks up the latest date and latest change made to the record. I would like to modify this report to include ALL the changes made to the record, so if the field RecordChanges of the data source has 3 dates, I would like this record to appear in my Crystal Report 3 times, once for each change that was made. How to parse the field I can figure out but where I'm stuck is how do I make the number of times a record appears equal to the number of dates found which is my {#DateFound} field?
There is a lack of details, but as far as I understood the problem and assuming that you did state in the comment that "there wouldn't ever be more than 5 changes to an order", here is a first try to tackle the situation.
I will assume that you already have a formula that "parses this text field and picks up the latest date and latest change made to the record". And that you know how to adjust this formula to pick up each of the record changes. I will name this formula as {#Parser1}.
Based on {#Parser1}, create other 4 formulas: {#Parser2}, {#Parser3}, {#Parser4}, {#Parser5}. As you probably presume, each formula must be changed to parser the Nth occurrence of the record change.
Create 5 details sections.
Put each formula in each detail section.
Suppress the detail section wich formula is null or empty.
That's it.
The limitation is that you can have at most 5 record changes.
This is an awkward solution, but it is necessary (as far as I know) since Crystal Reports works based on your data rows. It iterates over the rows, but cannot "generate" more rows by itself. If you can manipulate the data source, you can create other solutions.
You still need to do the magic trick to pickup the Nth change from the text.

Crystal reports - Can't filter on custom formula number field

Crystal reports don't let me use a custom count formula field to filter which transactions to show in a manager report.
I'm creating a Crystal report that team leaders are supposed to take out to see on how many occasions their employees have reported in sick. A record is only supposed to show if that person has reported in sick 6 or more times the last 12 months.
The report shows a record (a page) for each employee belonging to the managers organisational unit. Below the employee information is a subreport where I show the transactions from the salary/time system. Using select expert, I have filtered out the transactions that is supposed to show. I have then created a database field that count which day was 12 months back from today, and filtered so that only the transactions falling into this period shows.
My last problem is that I only want to show the record that has a minimum of 6 such transactions during the period. I created a formula field named #Antal ("amount" in Swedish) that simply counts the distinct number of dates in the "from"-date for the salary transactions I'm showing (since a change of law 2019-01-01 we needed to create a new transaction type, so some of the occasions after 2019 may have two transactions referring to one sick leave, thus I'm counting the first day of the period instead), DistinctCount ({P_LSTAT.P_SXXX06})
Now, the subreport has a new column with Antal (amount) that counts the amount of the desired salary transaction. I then try to use the selection formula to only show records where {#Antal} >= 6 but I get the following error:
This formula cannot be used because it must be evaluated later
Is there any other (better) way of doing this, or am I simply missing something?
For your selection based on {#Antal} >= 6 you need to use the group selection formula, not the record selection formula. Record selection is used to select records which meet the criteria before reading in the data. Group selection is used to filter out entire groups of records based on summarised values, after the records have been read in and the summaries calculated - which sounds like exactly what you need here.
The value of a Formula Field is out of scope when the Select Expert is evaluated.
There is no process for calculating the value of a Formula Field before it is printed within the section of the report it is placed. The Select Expert is evaluated prior to any section of the report being printed, so at this time all Formula Fields are effectively Nothing.

Crystal Reports: Accessing printed records

I've been working on a report that uses subreports to print records.
The problem is: for the same information, there may be several records - i.e.:
There may be several records for the same product if those records differ in one single column. My goal here is to make a Record Selection Formula that says: "if that item is already shown, then don't show it once again."
I've tried to use (shared) variables for this, but can't seem to find the way, because of the evaluation time.
Selection formulas are already being used to apply some filtering criteria. The column that may differ between two ocurrences of the same record is not always the same, so using a simple Selection Formula is not likely to work...
Any suggestions?
Example:
I used the record selection to tell the report:
"Show me all the products according to these criteria (warehouse=parameter1 and category=parameter2 for example)".
But there may be more than one record for the same product of the same category and inside the same warehouse, if one or more fields are different (for example, different price, different lot)
I want not to display those repetitions.
Your approach is wrong... Record Selection Forumula is something that is applied at report level not on the row level or column level.
If you requirement is not to show the records that duplicates then you need to write the supress condition for those, As per your requirement apply supress condition to the rows or columns.

SSRS 2008 limiting scope based on expression

I have a fairly simple problem, but I don't think I understand SSRS and scopes well enough to figure this out.
What I have is a case (one entity) that can have multiple appointments (another entity). Appointments have a date and a status. I want to display the next soonest appointment date and its status. To display the date I'm using
=Min(IIf(Fields!appt_start.Value > Globals!ExecutionTime, Fields!appt_start.Value, Nothing))
The idea is that I first pick only those appointments that occur in the future, and then grab the soonest one. It seems to work great.
Now, I need to apply the same filtering logic, but display the appointment status rather than the date. From my understanding, this is where scopes would come in. I could limit my scope to just the appointment I want, and then show its status. But I don't understand how to do that.
One way to go about this particular problem would be to use a filter in combination with the First function. Add a filter to the table to only show dates greater than the current day. Use a table row with no grouping and use expressions like this:
=First(Fields!appt_start.Value)
=First(Fields!appt_status.Value)
Another option would be to add calculated fields to the dataset to only populate values such as status when the date is greater than the current day. This is useful if you need to show more information later on.
Edit: Yes, you would want to sort the data by date for the First function to work right. You can actually filter at 3 different levels in SSRS. Right-click on your dataset and go to Dataset Properties. Click on Filters. Click Add. Fill in the expression, operator, and value to meet your need. You can also do this in the group properties or the table properties.