Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to calculate dollars per capita

Status
Not open for further replies.
Jun 20, 2011
1
US
Hi Folks,

I have a crystal report, cross-tabular, that displays unique client count and sum of dollars appropriately. I am attempting to have Crystal figure out the dollars per capita for me via creating a formula but am having a hard time with it. What I need to do is DistinctCount(People Identifier)/Sum(Dollars) and somehow have it do that within the appropriate grouping in the grid? Any help would be greatly appreciated!

Thank you,

Joe
 
You have the formula backwards, but anyway. First select the dollars summary in the inner cells and total areas->right click->format field->common tab->suppress->x+2 and enter:

whileprintingrecords;
numbervar sumx := currentfieldvalue;
false

Then select the distinctcount summary for inner cells and totals->right click->format field->common tab->suppress->x+2 and enter:

whileprintingrecords;
numbervar cnt := currentfieldvalue;
false

Then create a formula {@0}:

whilereadingrecords;
0

Add this as your third summary->select it in the inner cells and totals->right click->format field->common tab->DISPLAY STRING->x+2 and enter:

whileprintingrecords;
numbervar sumx;
numbervar cnt;
if cnt = 0 then
"" else
totext(sumx/cnt,0)

If the dollar field is a currency, then change the "numbervar sumx" to "currencyvar sumx" in all formulas.

You are essentially making use of the formatting formula areas so that you can use a form of running totals within the crosstab.

You should always identify your Crystal version when posting, since if affects what solutions apply.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top