Expression column with ABS

  • Thread starter Thread starter Kartic
  • Start date Start date
K

Kartic

I want to add a Expression column for all the negative amount and want to
show them as positive. What am I doing wrong in my code. It shows nothing
when amount is negative.

dsAccounts.AccountBalanceDetails.Columns.Add("Credit Amount",
GetType(Decimal), "Iif(Amount <0 ,abs(Amount),0)")

Please help, Thanks
Kartic
 
I'm not sure that abs() is supported as an expression. As a workaround you
can multiply by -1:

dsAccounts.AccountBalanceDetails.Columns.Add("Credit Amount",
GetType(Decimal), "Iif(Amount <0 ,Amount*(-1),0)")
 
Kartic said:
I want to add a Expression column for all the negative amount and
want to show them as positive. What am I doing wrong in my code. It
shows nothing when amount is negative.

dsAccounts.AccountBalanceDetails.Columns.Add("Credit Amount",
GetType(Decimal), "Iif(Amount <0 ,abs(Amount),0)")

Abs is not a valid function. Have a look at the documentation of
DataColumn.Expression. There the available functions, expressions and
operators are explained.
 
Back
Top