cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in Formula Workshop on SAP Crystal Reports 2016

cleomari
Discoverer
0 Kudos
109

Hi there

I have an issue in CR. I've tried to implement a formula that allow to change automatic the quantity of decimals in a field, according with customer's requirements, they want to display this specific field with dynamic decimals depends of its units of measure on the report. For this I followed the procedure below:

1. In format editor, I selected Custom Style and then Customize. In decimals, I selected Formula Workshop to implement a code.

2. I tried with two codes to get the goal. One using if statment and the other using case. I need evaluate a field where are showed units (Kg, Ton, bbl, gal) and according with the specific unit, other field that represents the quantity (volume or weigth) change dinamically its decimals quantity.

For gal and bbl --> 2 decimals

For Kg --> 0 decimals

For Ton --> 3 decimals

I used several codes but with any sucessfull results.

1. If + Round function

If ({Command.Unidades} = "gal" or {Command.Unidades} = "bbl") Then

ROUND({Command.Volumen_Peso},2) Else If ({Command.Unidades}= "Kg") Then ROUND({Command.Volumen_Peso},0) Else If ({Command.Unidades}= "TM") Then ROUND({Command.Volumen_Peso},3)When activate Sintaxs Check says: "No errors found"/ But when I save and close I get: "Bad Formula Result" 2. Select + Case + Round FunctionSELECT {Command.Unidades}CASE 'gal': ROUND({Command.Volumen_Peso},2) CASE 'bbl': ROUND({Command.Volumen_Peso},2) CASE 'Kg': ROUND({Command.Volumen_Peso},0) CASE 'TM': ROUND({Command.Volumen_Peso},3);

When activate Sintaxs Check says: "No errors found"/ But when I save and close I get: "Bad Formula Result"

3. Select + Cse + ToText FunctionSELECT {Command.Unidades} CASE "gal'": ToText({Command.Volumen_Peso},2)CASE "bbl": ToText({Command.Volumen_Peso},2) CASE "Kg": ToText({Command.Volumen_Peso},0) CASE "TM": ToText({Command.Volumen_Peso},3);When activate Sintaxs Check says: "A number, or currency ammount is required here"
Please, someone could give an advice about the issue? Fields Command.Unidades is String and Command.Volumen_Peso is Numeric.
Thanks in advance,Regards,

Accepted Solutions (0)

Answers (0)