Is there a way to convert varchar to numeric in the calculated field window?
I’m trying to make some fields in this query so that whenever the TAX MiscCode is shown, it will display the MiscAmt.
This is my calculated field: “(case when ShipMisc.MiscCode = ‘TAX’ then ShipMisc.MiscAmt else ’ ’ end)”
Obviously it gave me this error - "Severity: Error, Table: , Field: , RowID: , Text: Error converting data type varchar to numeric.
is there a reason why you can’t just have 0 instead of ’ '?
if 0 is not ok then use NULL: (case when ShipMisc.MiscCode = 'TAX' then ShipMisc.MiscAmt else NULL end)
While it is possible to convert varchar to numeric, it’s extremely complicated… think about it this way:
If I have ‘A’ and I want to display that as a number, what should it be?
Well it would depend on how you would want A to be interpreted numerically… and there are different ways to do that.
The reason why I had ’ ’ instead of a 0 was because originally I had - case when ShipMisc.MiscCode = ‘TAX’ then ‘TAX’ else ’ ’ end. I then made a couple different calculated fields to cover the rest of the MiscCodes.