Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: distinct count Formula help Post Reply Post New Topic
Author Message
mkhenneman
Newbie
Newbie


Joined: 23 Jan 2012
Location: United States
Online Status: Offline
Posts: 7
Quote mkhenneman Replybullet Topic: distinct count Formula help
    Posted: 11 Apr 2017 at 5:04am
All

I'm having an issue with doing a distinct count.

I have a field that represents an account number and it has letters and numbers, so it's a string. I have the field grouped and anytime the account number appears more than once, I want it to be counted once.

example of data

group

3/29/16    lisdexamfetamine    Z921936
3/22/16    guanFACINE ER       Z921936

I want to count that account number 1 per group


I created a variable that's a number that will return a 1 if there's an account number or a zero if not but that won't let me summarize either

3/29/16    lisdexamfetamine    Z921936   1
3/22/16    guanFACINE ER       Z921936   1
4/1/17     texctrune                     0

not sure what else to try...any help?


Edited by mkhenneman - 11 Apr 2017 at 5:28am
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 12 Apr 2017 at 5:18am
Are you trying to summarize a summery, if so, then you cannot do that unless you create your own running totals in formulas.
IP IP Logged
mkhenneman
Newbie
Newbie


Joined: 23 Jan 2012
Location: United States
Online Status: Offline
Posts: 7
Quote mkhenneman Replybullet Posted: 12 Apr 2017 at 6:18am
I do believe that's the problem. Do you have an example how you would create this work around? thank you.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 12 Apr 2017 at 9:48am
I did not read specifically what you are trying to achieve.  But generally you have three formulas.  One to reset the shared variable (you could use global variables but they do not work for me for some reason), i.e., shared numbervar counter := 0;  normally in the report header or a group header. Second the calculation;  shared numbervar counter;  if someconditon the counter := counter +1;  Then the third formula to either display the value or use it in another formula.


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Apr 2017 at 6:51am
you can also consider a formula that concatenates the group field value with the account number and do a distinct count of that (at both group and report levels).
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.