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

Cross Tab printing decimals 1

Status
Not open for further replies.

quisar

Programmer
Aug 21, 2002
45
IN
Hi,

We are using crystal reports 7.0 and have used crosstab to print the below report:
Branch1 Branch2 Total
Qty Val Qty Val Qty Val
Product1 1 9.5 2 8.1 3 17.7
Product2 2 3.7 3 3.2 5 6.9
.
.

The no. of products and branch can increase. To print the above a view is created but the qty and value is field is taken in the same column. if it is taken separately then it will print it in two rows.
Now the problem we are facing it is, no decimals is required and value requires decimal. How will i format the same column displaying decimals for value and no decimals for qty using the same column. There is a flag "Q" for quantity and "V" for value.
We tried using a formula in that column in decimals. If it doesn not get in to the IF then else case.

Pls help.

Quisar
 
It took me a while but I get it now. Use a conditional formatting statement on the field.
Highlight the field. Click on Format field. Go to the number tab. Click on the formula button next to Decimals. Use this formula
If {Type} = "Q" then 0 else 2
 
Thanks for replying JohnEck.

I have tried this.
If {Type} = "Q" then 0 else 2

then ,it formats both the columns with no zeroes.

and If {Type} = "V" then 2 else 0 then the format of both the columns is formatted to 2 decimals.

Do you have any other solution?

Quisar



 
Sorry I posted the solution without testing. It appears you cannot do conditional formating in crosstabs based on those collumn headings because of the way cross tabs are calculated. you could do a cross tab view in you database so you have a seperate colomn for QTY and Value then then build your report with two seperate sumarry fields which can be formated differently.
 
The function you need is the GridRowColumnValue () which is not availble in v7. Your only other options is to use this formula for your conditional decimals:

if CurrentFieldValue = Round (CurrentFieldValue) then 0 else 1

This will take off the decimals of any number when the value is an integer. Now, the quantity is the only one likely to be an integer, so this should get you very close. If your VAL happens to be an exact integer, it will also lose its decimal place.

If this isn't close enough, you will have to upgrade.



Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
Will the problem be solved if I update to crystal report 8.5

Quisar
 
The function that I mentioned should do what you want, and it is availble in v8.5

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
Thanks kenhamady. The solution you gave worked. The onl;y problem being if VAL happens to be an exact integer, it also loses its decimal place.

We also have crystal reports v 8.5. I will try if this problem can be solved using 8.5

Thanks,

Quisar

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top