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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grouping by: sometimes number or string

Status
Not open for further replies.

JeroenBoon

Technical User
Aug 15, 2002
106
NL
Hello,

I have the following problem:
I want to make the grouping in a report flexible in this way:
{@group} formula:
if {?group}='amount' then INT({@turnover}/5000) else
if {?group}='BU' then {@Businessunit} etc

where: the result of INT({@turnover}/5000) is a number and {@Businessunit} is a string. Now CR tells me that either the first has to be a string, or the second has to be a number: they both have to be the same. But when I convert INT({@turnover}/5000) into a string, the groupsorting isn't anymore like I want it (I want a decreasing order based on the numbers and not an 'alhpabetical' order)

What to do?

Thanks, Jeroen.
 
I am assuming this is because the number of digits in your result for the number value can vary. You can correct this, I think, by formatting the value to display zeros in empty places:

totext(int({@turnover}/5000),"0000")

Add as many zeros as the maximum number of places. This should allow the sort to work correctly. You can use this for the group value, but still display your original value instead of this, if you wish.

-LB
 
Try to avoid the Crystal script readers for technical support, or better yet, try to confuse the front line of defense so that you immediately get escalated to a competent person.

Use something like:

picture(totext(int({table.field},0,""),"000000000000")

For the numerics.

This will pad the text with 0's which will allow for proper sorting/grouping.

You might offer to sell this solution to Crystal ;)

-k
 
so far so good, except for the results <0.
How do I do that?

Jeroen.
 
Use an If, as in:

if left(totext({Bob.Employee ID}),1) in [&quot;4&quot;,&quot;1&quot;] then
&quot;!&quot;+picture(totext({Bob.Employee ID},0,&quot;&quot;),&quot;000000000000&quot;)
else
picture(totext({Bob.Employee ID},0,&quot;&quot;),&quot;000000000000&quot;)

Use the above to group, and use the following for display:

if left(totext({Bob.Employee ID}),1) in [&quot;4&quot;,&quot;1&quot;] then
&quot;-&quot;+picture(totext({Bob.Employee ID},0,&quot;&quot;),&quot;000000000000&quot;)
else
picture(totext({Bob.Employee ID},0,&quot;&quot;),&quot;000000000000&quot;)

-k
 
problem solved, thanks guys (I assume you are guys...)

Jeroen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top