Skip to main content

Do you need to use t1 with the calculated column type?
 

I have the following calculated field code : btw_percentage / 100 + 1.00
However when I tried to add t1. to it. The database gave an error. 
But the code as it is written above doesn't work.

Does anyone know how to handle this?


 

Hi Maarten,

Specifying t1 is not needed as the column is in the context of the table already. No other tables are available, thus always selecting out of the same table.

What is exactly not working? 

One thing I can think of is that btw_percentage has a datatype of type INT. This will not go well with dividing and such. 


@Mark Jongeling  btw_percentage is indeed of the datatype int


SQL server will see 21 / 100, for example, as 0, then + 1.00 is 1.00. This is not intended. When needing calculations like this, you'll need to ensure the tax percentage is of type Numeric (or similar).


As a rule:

  • Expression fields user t1.column_name
  • Calculated columns (no prefix) column_name
  • Calculated columns (via function) @column_name

As you to your code, when it's an INT you sometimes need to push decimals, I guess in this case you would like to make from 21% a factor 1,21 right?

(100.0 + btw_percentage) / 100.0 

If above still gives an error you can always cast btw_percentage as a decimal(5,2) for example. 


Please see this related idea, which will be available in the next platform release: 

 


Reply