Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Help with Multiple Values in single field Post Reply Post New Topic
Author Message
Philanna
Newbie
Newbie


Joined: 17 Jun 2014
Location: Australia
Online Status: Offline
Posts: 3
Quote Philanna Replybullet Topic: Help with Multiple Values in single field
    Posted: 18 Jun 2014 at 1:15pm

I hope someone can help me.

I am creating a report based on donors giving to an area.  I need to count how many donors have;

A) given only to the area the report is based on

B) Given to only other areas

C) given to the area and any other area.

The problem I am having is the information on the area is listed in one field so I can’t use a simple Boolean formula to exclude or include donors.

The information looks like this

Donor   Area

2010       Cat

                Cat

                Dog

                Horse

2011       Cat

                Cat

                Cat

2014       Dog

                Horse

                Rat

 

I have successfully pulled the area information into an array and can use the array to look for Either A,B or C.  But I then can’t do a count of how many are A,B or C.

How can I get around this issue.  The way our data is set up I am going to run into this situation often so I am keen to find a solution.

Thanks everyone.

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 19 Jun 2014 at 5:01am
depending on how your array is set up...
if the array is just to find the area for a donor, you could start a second array and increment the value in the corresponding index, say you have 2 arrays area and areaCount, index 1 = cat in area, and you can set keep a count of how many times cat has come up in areaCount.

It's a thought

HTH
IP IP Logged
Philanna
Newbie
Newbie


Joined: 17 Jun 2014
Location: Australia
Online Status: Offline
Posts: 3
Quote Philanna Replybullet Posted: 22 Jun 2014 at 8:51pm
hi lockwelle - thanks for your response. 

I think I had better explain in more detail. 

Ok so this is how I currently have things setup

My data is grouped by Customer and then Fund category.

I have three formulas,

In Group header 1 - Initiate Array

Shared numberVar x:=1;

In Group Header 2 – load Array

Shared numberVar x;

Shared StringVar array fund_Category;

if not({GfFnds_16Fn.GfFnds_16Fn_Fund_category} in fund_Category ) then  //checks to see if already in array

( 

    x := x + 1;                                                            //This is where the values are added to the array 

    redim preserve fund_Category[x]; 

    fund_Category[x] := {GfFnds_16Fn.GfFnds_16Fn_Fund_category}; 

); 

fund_Category[x]; 

In Group Footer 1 – Print array

Shared stringVar array fund_Category;

Shared Stringvar all_Categories;

all_Categories := Join (fund_Category, ","); // Use Join function to print array on one line

mid(all_Categories,2);

 From here I can determine if a donor is one of the three categories with a simple this then else formula, but I can’t sum (total) how many donors are in each category. 

This report is in the early stages so I am more than happy to scrap what's been done so far and start again if it will work.


Thanks in advance


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 25 Jun 2014 at 5:03am
what I was suggesting was that you could keep count of the donors in each category like this:
shared numbervar array category_donor;

if not({GfFnds_16Fn.GfFnds_16Fn_Fund_category} in fund_Category ) then //checks to see if already in array
(
    x := x + 1;                                                            //This is where the values are added to the array
    redim preserve fund_Category[x];
    redim preserve category_donor[x];

    fund_Category[x] := {GfFnds_16Fn.GfFnds_16Fn_Fund_category};
    category_donor[x]:=1;
)
Else(
   //find the index of the category
   category_donor[x]:=category_donor[x]+1;
);

now, if you know the index of the category, you know how many donors were in that category

This is what you were looking for?


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Jun 2014 at 7:47am
not exaclty the same process you wanted but ...
you can also do this with a couple of formula (flag1 and flag2) summed at the group and then 3 running totals keying off those sums
//flag1 - used for seeing if the donor area exists
 if table.fund in report fundtype then 1
//flag2 - used to find if other typre exist for donor
 if NOT(table.fund in report fundtype) then 1
sum each of these at the donor group
now you can determine your 3 categories and use this same condition rule in 3 different runningtotals
A) given only to the area the report is based on
Sum(flag1,donor)>0 and sum(flag2,donor)=0
 
B) Given to only other area
Sum(flag1,donor)=0 and sum(flag2,donor)>0
 
C) given to the area and any other area.
Sum(flag1,donor)>0 and sum(flag2,donor)>0
 
So a running total for A would be
name=reporttypeonly
type=distinctcount
field=donorid
evaluate= use a formula
Sum(flag1,donor)>0 and sum(flag2,donor)=0
reset=never
place in report footer
 
repeat for the other two types using the correct evaluate formula
IP IP Logged
Philanna
Newbie
Newbie


Joined: 17 Jun 2014
Location: Australia
Online Status: Offline
Posts: 3
Quote Philanna Replybullet Posted: 22 Jul 2014 at 3:08pm
Thanks for your help guys.  I got it working once I had some time at work to look at it Smile
For anyone else with this issue what worked for me was the the solution offered by DBlank.


Philanna
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.047 seconds.