Group totals with supressed lines in Crystal Reports - crystal-reports

Have been googling this for a couple of days now and tried various posted solutions, also from Stack Overflow.
I'm making a report, where there is a check on two fields to see if they have been written before. If they are, they are suppressed
psudo-code:
If {customer} and {date} as previous then suppress.
This works fine, but I need to make a count for each group. If I use the built in count function, it also counts all suppressed lines and I am running out of ways to search for a way to solve this.
I have tried to add a custom formula, that counts within each group and resets before next group, but it keeps adding to the total in all the other groups. Have tried it with both shared NumberVar and local NumberVar

Never mind. Figured it out my self.
Some of the "posted solutions" to this specific error was not fitted exactly to my needs, so tried back and forth with various solutions.
When making a Running Total Field with group, it only works when it is set to reset with each group. If you encounter this and need help to fix it, then just ask away and I will help you :)

You have to use DistinctCount instead of using regular Count.
DistinctCount ignores duplicates and only counts records with unique value.
For example, if i have data like
customer | date
---------------------
john | 01.01.2017
john | 01.01.2017
john | 02.01.2017
and i use regular count(customer,date) the result would be 3. But if i use DistinctCount(customer,date) then the result would be 2.
Hope it helps

Related

Crystal Reports: different results from distinctcount

I work in an educational environment, and am building a report to count the number of course completions. Part of this is creating groups that filter by course managing organization.
Everything goes fine if I simply create a date field in the group and summarize it by distinctcount - I get the correct number of course completions by completion date. (I have a resource to independently verify this.) However, I also need to create a formula that will, eventually, calculate the average number of course sessions conducted per year.
With that in mind, I have tried to create a formula and insert it into the group, but every time I do this I get a completely incorrect number - it's a count of every single completion date, regardless of if it's distinct or not or even if it's in the single organization.
I've tried the following as a forumla:
Distinctcount({*data source*.*completion date field*})
and
whileprintingrecords;
Distinctcount({*data source*.*completion date field*})
and
numbervar sessions;
whileprintingrecords;
sessions:=distinctcount({*data source*.*completion date field*})
None of these work - they give the grand total of course completions.
I also tried whilereadingrecords, but it errors out on me and says "This function cannot be used because it must be evaluated later."
Can anyone help me out here?

How can we get a correct running total when we are suppressing a field if the check No's are duplicated?

We have a report which is grouped by contract/job, then by Invoice. Within the invoice section, there are details per check No. regarding how much the customer paid towards their invoice with that check. We don't want multiple lines per check, even though there can be multiple lines from the same check. In other words, we have suppressed the section based on:
{ARTL.Amount}=0 OR
{ARTH.CheckNo}=Previous({ARTH.CheckNo})
The problem is, if there are multiple lines per check, the amount is only pulling in the first amount in the list. For example, we have check 1234 that was for a total of $10,000. But, there may be one line worth $123 applied and the next line worth $500 applied. We want the first line to display the total amount, in this case, $623.
How can we do this? Running total does not seem to work and I have tried using a formula (see below) which also did not work.
IF NEXT({ARTH.CheckNo})={ARTH.CheckNo}
THEN ({ARTL.Amount}+{ARTL.Amount})
ELSE
{ARTL.Amount}
I also tried this formula:
IF {ARTH.CheckNo}=PREVIOUS({ARTH.CheckNo}
THEN ({ARTL.Amount+ARTL.Amount})
ELSE
{ARTL.Amount}
Any help is greatly appreciated!
Thanks.
Add a group on check #. Suppress the details (the customer's remittances against each check). Add a summarized field on the amount field. Include all relevant check details in the check #'s group header. Move the summarized field to the header and suppress the footer.

Crystal Reports XI - Suppress group header based on suppression status of sub-groups

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.

Crystal reports - Group total

I have a report that I've written and I understand how to create running totals and such, but need help creating a custom evaluation formula.
I have two levels of groups, first group is based upon a certain user, the next group is based upon transactions that user has been involved in. I have details hidden, and am only interested in the totals for a particular activity. This is working great, and totals are working properly but the problem is, each activity has a 'line number', which essentially can be the same as another activity (ie: two activities can have lines 1, 2, 3 contained within), so doing a distinctive total based upon a set of data isn't accurate because I only want it to be distinct based upon each individual recordset, and not globally.
The example is below... if I do a count on each record for this dataset, it comes out to 18 because there are duplicate line numbers on each... but if I do distinct, it only comes to 9 because of duplicate line numbers across multiple actives.
I guess what I need to know is how I can take the totals per detail group, and have them total up in my second footer properly. I assume it's going to take me compiling together a string including the activity number and line number, and then comparing them?
Here is an example of the data contained within the total groupings:
I figured this out on my own... turned out it was pretty simple. I converted my numeric values to text, and included a copy of the transaction id and the line id as my test value, and did distinct on that... Sometimes it just helps not staring the problem down.

Selectively showing groups in Crystal Reports

I have a report which displays information by group; I'd like to not show any group that doesn't have at least two items in it. Is there an easy way to do this?
Example:
Bob
3/1
4/3
Joe
3/2
3/7
3/9
Mark
5/9
James
John
8/17
9/2
Grouped on name, should not show Mark or James.
If your report is simplistic enough, you can get away with just suppressing the Group Header, Group Footer, and Details sections by using a summary function like count({table.somedate},{table.dudesname}) < 2. Note that the second parameter to a summary function has to be a field being used to group on.
Your mileage may vary with doing it this way. If you are displaying calculated summaries in the report footer, for example, it won't make sense to just suppress these groups as their data will still affect any report-level summary. The other problem you might run into is needing to use a distinct count on some field instead of just a count, depending on your table joins.
You could create a group-selection formula (Report | Selection Formula | Group...):
Count({table.field_to_count}, {table.grouped_field}) < 2