Datatable Expression Column Sum other column include Null Values

Hobbyist_programmer 621 Reputation points
2021-08-05T09:25:20.027+00:00

Hallo,

I have datatable with 3 columns with a datatype Long (Nullable) . Total colum is sum of other two columns in the datatable and i have a following expression set for the total column and it works only when other two column rows has value . if one of them does not have value then total is not shown. How can i correct it.

Column("Total"). expression = "Col1 + Col2"

120719-2021-08-05-11-20-02.png

Developer technologies VB
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.5K Reputation points
    2021-08-05T09:58:02.26+00:00

    Try this expression: "ISNULL(Col1, 0) + ISNULL(Col2, 0)".

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Hobbyist_programmer 621 Reputation points
    2021-08-05T10:08:54.343+00:00

    Hallo Viorel. It works but i dont want to see 0 when the sum is 0 i want to keep the total row empty if the sum is zero. tried Null, DBNull instead of 0 but not working.


  2. Hobbyist_programmer 621 Reputation points
    2021-08-05T11:14:48.577+00:00

    hallo Viorel. I am getting this error Cannot convert value '' to Type: System.Int64.'


  3. Hobbyist_programmer 621 Reputation points
    2021-08-05T11:38:53.067+00:00

    my data is something like this

    120841-2021-08-05-13-37-02.png

    i can change the column type in order to get the desired reult.


  4. Hobbyist_programmer 621 Reputation points
    2021-08-05T13:15:51.097+00:00

    .Expression = IIF(ISNULL(Col1, 0) + ISNULL(Col2, 0) = 0, '', ISNULL(Col1, 0) + ISNULL(Col2, 0))"


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.