cancel
Showing results for 
Search instead for 
Did you mean: 

Determine field type before processing

Former Member
0 Kudos

I've inherited a .xls file that i wish to process in Crystal.

But when a "number" filed type is blank, its actually returned as a string type with blanks.

this formula

round(tonumber({data.Capacity}),2)

fails with "the string is non numeric" when the filed contains the blanks

and this formula

if {'Capacity} = "" then tonumber(0.00)

else

round(tonumber({data.Capacity}),2)

fails with "expecting a number" when the field type is number

Is there anyway i can determine the field type before processing ?

i.e if "fieldtype= number"

then round(tonumber({data.Capacity}),2)

else if "fieldtype=string"

then round(tonumber({data.Capacity}),2)

Accepted Solutions (0)

Answers (1)

Answers (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi John,

With a .xls datasource it gets a little tricky.

The datatype of the fields is determined by the first row in each column.

You could try this code:

stringvar y := totext({data.capacity});

if isnumeric(y) then

     round(tonumber(y),2)

else 0

-Abhilash