My SQL Stored Procedure returns following result:
ID District Decision
-----------------------
17 First Approved
17 First Partially approved
17 First Pending
17 Second Approved
17 Second Partially approved
17 Second Pending
The same was generated in my Crystal Reports. District and Decision columns have no any relationship. Both of them only related to ID (requestId). I'm getting duplicated results for each District as the result of joining 3 tables.
So far I was able to group records by ID and suppress duplicated rows. After doing so I've got following in my Report:
ID District Decision
-----------------------
17 First Approved
Partially approved
Pending
Second Approved
Partially approved
Pending
So far so good, but what I eventually want is to get is something like follows:
ID District Decision
----------------------
17 First Approved
Second Partially approved
Pending
I want all blank spaces to be removed (which is left after suppressing duplicated) and leave only distinct records within ID group.
I want to do everything in Crystal Reports, that's why i'm excluding work around in the SQL server
If editing the SQL isn't an option, you're on the right track. In short you'll want to:
Write a formula (#YourFormula) that evaluates True if the previous record has the same ID and District. (Hint: use the PREVIOUS() function.)
Format each field in your Details section such that the Suppression formula is set to #YourFormula.
In the Section Editor for Details, check "Suppress Blank Section".
This all hinges on whether or not your records are grouped correctly. If they sometimes appear out of order, you might need to edit your current SQL after all.
Related
I am extracting information on medication requests. For each medication request, say in the last 90 minutes, I also want to display a date for any previous time a drug was dispensed for the same patient. In many cases there will be no such history as its the first time the patient has had this drug.
I cannot seem to both show the most recent dates for those patient/drug combinations where there is a prior date but keep the records where there is no history of a prior drug being dispensed.
I have utilised Report, Selection Formulas Group as has worked in the past with different queries.
{#DispenseDT}=MAXIMUM({#DispenseDT},{#RefDRUGPATID})
NB DispenseDT is a formula joining Dispensed Date and Dispensed Time
NB RefDRUGPATID creates a unique reference for each Drug and Patient combination.
This appears to work in pulling through the most recent dispensed date/time for each DRUG/PATIENT combination. If I don't do this I get the first (oldest) record.
However, when I apply this I also lose records. I think this is because not all the DRUG/PATIENT combinations being requested have had previous records so when the formula cant find a MAXIMUM it excludes the record entirely.
I have tried doing something like if isnull({#DispenseDT}then " " else
ToText({#DispenseDT}=MAXIMUM({#DispenseDT},{#RefDRUGPATID})) but when I try and create a formula and display this I just seem to get either BLANKS or TRUE or FALSE displayed, not the "MAXIMUM" DispenseDT. It doesn't like me putting the formula within SELECTION FORMULAS GROUP either.
So in summary I am looking to pull the most recent historical dispensing date for a patient/drug combination for each new request made. But where there is no history of a drug being dispensed I still need to see the new dispensing request record.
I am using crystal reports 13.
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.
I have my sql database Views available to my report, but sometimes they return multiple values, for example I have one that shows me the Total Credits for a range of years.
When I click "Browse Data.." it lets me see what bits of data are available
Eg:
Credits
-------
31
45
460
But I want to select 45 (based on a customer ID)... is it possible to do this?
EDIT: An alternative is if I can link the Customer ID from two views, but only if it's not null (as sometimes there are no records in the Credits)
To avoid the problem of unintentionally "deleting" customers from the report results, first do a left outer join between the CONTRACT_VIEW and the year views, such as TOTAL_2013. In your selection formula, instead of just doing something like {TOTAL_2013.Customer_ID}=MyCustomerID, add all the nulls to it as well, so: isnull({TOTAL_2013.Customer_ID}) or {TOTAL_2013.Customer_ID}=MyCustomerID. This will prevent customers who don't have any entries in the by-year views from being removed completely from the report.
I have made a report that shows transactions in a certain time period for certain products.
To simplify it; its based off 3 tables: Transaction, Product and Customer. Transaction joins to Product and Customer by keys ProductID and CustomerID respectively. The product can be used by several customers though, so there is no join between customer and product.
The report is structured as below:
Report Header:
-Group Header 1 - CustomerID (prints name, id etc)
--Group Header 2a - Product Code (prints name, description..)
--Group Header 2b - sub report GetOpeningBalance
---Group Header 3 - Transaction Date
----Details (nothing printed)
---Group Footer 3 - Prints transaction date, details, new balance
--Group Footer 2 - Prints Product closing balance (opening - transactions).
-Group Footer 1 - Prints nothing.
Report Footer - prints nothing.
The sub report GetOpeningBalance calls a stored prodedure and returns a number in a shared variable corresponding to the opening balance. This is then incremented/decremented by each transaction and the closing balance is displayed at the end.
Now the selection formula is based on: Customer, Product and Date Range (to/from). Customer and Product can be discrete, range or discrete + range values.
This worked fine; it showed product transactions which occured in the range given and displayed numbers. The customer however wanted it to show all products; even if no transactions had happened in that time period. For example they had stock; but there were no intakes/outtakes so the opening and closing balance are equal.
So to solve this; I removed the date range parameter in the selection criteria (so it returns all transactions for the product) and have then supressed any detail lines that fall outside of the wanted date range. I have modified the running total formulas accordingly so they only include the "shown" transactions.
Now I am experiencing strange behaviour. Complete groups can be duplicated on the next page.. Say products 1-9 are printed on page 1, you would expect page 2 to start with product 10 and so on. However products 1-9 are printed; but then products 8 AND 9 are printed again at the start of page two . It prints the full section including the correct totals.
This behaviour is not consistent; it wont do it on every page or for every date range/product selection.
I have attempted ticking/unticking keep together in the Section Expert and the Group Expert. I have also tried removing some extra groups and details to try narrow it down to no avail.
Are there any options or settings that may be causing these groups to be reprinted?
I would usually use a subreport for the details section in these kind of problems; however because there is no direct join between product and customer it makes it impossible.
I had some free time to play with this today.
I found that switching the Group Header 2a with 2b; so that the subreport is before the product details header will stop this behaviour happening.
Now to test, test, test!
I'm trying to show employees at a company grouped by worked and still working (in vs2005 crystal reports).
The user can pass by parameter a list of companies they want to show.
Tables: VRP-COMPANY, VRP-COMPANY-OPPORTUNITY, VRP-OPPORTUNITY-PRODUCT
The record selection formula: {VRP-COMPANY.COMPANY company} in {?companies}
Grouping is done on: VRP-COMPANY.COMPANY company, then formula to decide its working or worked and then on productname.
Now when I run the report I only get to see the companies who have got entries in the VRP-COMPANY-OPPORTUNITY. I want to see the company name (group) even if there are no entries in the opportunity table. How to do this in Crystal Reports? I tried Left join between company and company-opportunity tabel but no effect.
I found the problem. Left join was correct but I had an additional select formula (on opportunity status to be closed-won. Therefore it let out the record. The record can also be null when there are no opportunities.
Should the question be deleted?