Expression column with ABS

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
 
S

Steve DuMosch [MSFT]

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)")
 
A

Armin Zingler

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top