crystal report group on multiple criteria - crystal-reports

This is a strange scenario that I'm having trouble working out:
I have a report that needs to show the summary of donations that each board member gave/got in any fiscal year. They get credit for hard credit donations, soft credit donations, and solicited donations. Meaning their record ID number is in 3 columns throughout the spreadsheet.
So, my data looks like this:
Soft Credit ID/Hard Credit ID/Solicitor ID/Gift Amount
1/-/-/$50
-/1/-/$100
-/-/1/$250
I need to be able to group these records together because they each have the ID # "1" in the record (but in a different column each time). I need to group these records together, so that it shows the summary for each board member, with the details below:
Board member ID 1: Total Giving $400
Soft credit - $50 - 4/1/13
Hard Credit - $100 - 3/29/13
Solicitor Credit - $250 - 7/2/13
(^These don't need to be summaries, this just needs to list all gifts and which kind of credit they give)
I'm having trouble because I don't see a way to group based on the ID, in different fields. I tried grouping based on a formula for each board member (formula read {Hard Credit ID}="1" OR {Soft credit ID}="1" OR {solicitor credit}="1") but it didn't work and it creates a hierarchy that I'm not looking for. Apologies for the formatting - I can't find instructions on how to make that block above appear as a table.

One way to do it, depending on your source DB, is to use a SQL Expression to condense the three fields:
coalesce({table.SoftCreditID},{table.HardCreditID},{table.SolicitorID})
Or you can do it in a regular formula:
if not(isnull({table.SoftCreditID)) then {table.SoftCreditID}
else if not(isnull({table.HardCreditID})) then {table.HardCreditID}
else {table.SolicitorID}

Replace nulls in the three fields with 0 and then concatenate. You will then have a possibility of three values in the new field: 100 010 001
If you concatenate the three ID fields into a new field without replacing the nulls then you will get "1", "1" and "1". If you replace the nulls with 0, then you will get "100", "010", and "001". Now, you can group-by on the new field and you will get subtotals, or skip-group-by and just list the detail. To extract the description of the code, if we are only talking about 3 possible values, you can use nested if statements to examine first value and test if it equal to "100", else test if equal to "010", else test if equal to "001", else error. Or a case statement, syntax examples here: Select/Case in Crystal Reports or Crystal Reports SELECT CASE statement

Related

Crystal Reports - Running Total is duplicating if a group has more than 1 "detail"

I have a report that I am trying to get working in Crystal. Basically the report is about gifts (I work for a non-profit). I grouped the report by Payment Method, and then Gift ID, which is a unique field in the .MDB file used to fuel the report.
I want to keep gifts with the same payment method together, which is why I first grouped by that. Then I grouped by Gift ID. the "Details" of my report is a field called Soft Credit Donor, which will list out as many donors that were given soft credit on the gift. There could be 0, there could be multiple...I show running totals in the Report Footer. I have a Gift Count (a Distinct Count of Gift ID, evaluating on each record, resetting Never), a Sum of all Gifts (a sum of Gift Amount, evaluating on Change of Field - Gift ID, resetting Never). These 2 fields work fine.
Then I get to where I want a running total based on each Payment Method. I am able to easily show the # of gifts per payment method. I do this with 4 separate running total fields (one for each payment method). I am doing a Distinct Count on GIft ID, evaluating on a formula (payment_method = "Business Check", "Personal Check", "Credit Card", etc...and Resetting Never.
My issue is when I try to do a $$ total for each payment method. In this case I am seeing that my running total is duplicating if there is more than 1 "detail" or soft credit donor. My running total field is doing a sum of the Gift Amount field, evaluating on a formula (payment_method = "business check", etc...), and I've played around with the Resetting. If I choose Resetting Never, then I am seeing the money being double or triple, etc...counted. Depending on if gift has more than 1 "detail". If I choose to reset on change of field and I set that to either Payment_Method or GiftID, I get a blank running total.
One thing to mention is that my MDB file has multiple tables that are all left outer joined to the main table which holds the Gift ID and Payment method fields. So there is a Soft_Credit table that holds the Gift ID field, along with the each name of the Donor who gets a soft credit. I'm not sure if that matters or not.
I'd appreciate any help!
You can put this in a formula:
If {payment_method} = "Credit Card" Then 1 Else 0
Use this formula as sum in the running total.
Use "on change" on the id field.
User "never reset" for the total sum.
You have to create one formula and one running total for each payment method.

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 Incorrect Grand Total

I tried looking for the answer but all the questions were more complicated, needing more complicated answers.
I'm trying to find the sum of a column in Crystal Reports, putting it into the footer, but when I do it gets a grand total that is totally incorrect. For example, i want to find the sum of the column balance, which has only got one row with £0.68, but CR puts £69.36. I have had to suppress the duplicates, so that probably has something to do with it, but since i'm new to everything code related I need some help.
The duplicate values you are seeing most likely are not a bug, but rather are data columns that have a many-to-one relationship with other data columns in a joined data table. Which is when grouping your data becomes necessary. For example, within a database one Invoice record typically joins with 1 or more Invoice Detail records. Each Invoice Detail record will have the same Invoice Number, and you will have duplicate Invoice Number values in your report. You say you begin by filtering your report to a single customer, but if that customer has more than one invoice, without a grouping level on Invoice Number, then the details section is the only place you can print the Invoice Number and it will duplicate over and over again for each item on the invoice that is defined on your Invoice Detail table. By grouping on Invoice Number you can use the group header section to print data fields that have a 1-to-1 relationship with any one invoice without duplicating them. Then you can use a summary field in the group footer section that properly reflects your grouped data without counting the duplicate values.

LookupSet based on two fields combined instead of one

I have two datasets: Dataset1 (primary) and Dataset2. My report dataset is Dataset1.
I want to access Gross premium Amount from Dataset2 and put it in the report. The report is working just fine if the parameter for "market name" is a single value parameter.
When I set the parameter properties to "Allow Multiple Values", my report is displaying wrong Totals for "Production" Field. The problem is because the lookupset function is based on Currency_Type.
What I should do is search for each Market Name and for each currency type, then search for the appropriate Gross Premium in second dataset and return the value.
Dataset1:
Market Name Currency Type Receivable
Dataset2:
Company Name2 Currency Type1 Gross Premium Amount
The results should be like this:
Market Name Currency Type Receivable Gross Premium Amount
I used this code if to search for one value:
=code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))
What should I do if I want the lookupset based on Market Name and Currency Type combined?
Can you join the datasets in your query? That would be a lot easier, if it's possible. Otherwise you need to have some way to break apart your multi-value parameter, such as a including it as an element in your first dataset. (Maybe even a cross join if appropriate.)
But to directly answer your question
What should I do if I want the lookupset based on Market Name and Currency Type combined?
[Note that this doesn't have much to do with how to lookup a multi-value parameter.]
I have solved this problem by creating a key from the two pieces of information in my queries themselves, such as with string concatenation, but you can also do the same in your LookupSet function:
=LookupSet(Fields!Currency_Type.Value +"-" + Fields!MarketName.Value, Fields!Currency_Type1.Value + "-" + Fields!Market_Name.Value, Fields!Gross_Premium_Amount.Value, "DataSet2"))
This will only work if MarketName is a value in your first dataset.

Display records side by side

I use a DataTable to bind my crystal report. It contains columns for credit and debit. If either one is zero, so is the other. Therefore every column contains either credit or debit information. I want to display something like:
Bank Name(Credit)|CreditAmt|BankName(Debit)|DebitAmt
My first column needs to display credit records with the bank name, and the second column displays Credit Amount and same logic for Debit amount - which displays in 3rd and 4th column.
My output currently looks like:
HDFC Bank | 550 |(blank) | 0
blank) | 0 | 500 | HDFc bank
I get blank a space and 0 in any section either credit or debit - because I only get the credit or debit amount per record. Therefore it puts 0 and blank spaces for other sections. How can I suppress th blank section to look like the following?
HDFC Bank | 550 |(blank) | 500 |HDFc bank
What you need to do is summarize your transactions by a common column to both your Debit and Credit. I assume Bank Name is the common link. Then summarize your Debit and Credit. Here are the steps to take:
Menu Insert->Group (Select the column common to your Dr. and Cr.)
Menu Insert->Summary (Select your Dr. Column and use SUM)
Place the results on the Group Header line
Menu Insert->Summary (Select your Cr. Column and use SUM)
Place the results on the Group Header line
Hide your details line
Now to further your understanding of what we are doing here, suppose you wanted to summarize by the accounts per bank. You'd do step 1, then insert another group by Account and then add the summarized Dr. & Cr. to the Account Group Header.
Cheers.
Grouping solution is great.
Another possible solution is:
- creating a formula field called NextDebit that gets Debit value from the next line Next(Debit)
- show in Detail Section Credit and NextDebit
- suppress details where Credit = 0
Another solution i working on the query, so that you'll have just the data you need in the way you need to work on.