Skip to Content
Sep 19, 2019 at 08:38 AM

Issue with arithmetic operation in CDS views.



I am trying to add two fields of one CDS view in other CDS view. I am getting Zero as the output if any of the operand is Zero.

In the first CDS I am getting the SUM of sum field as

 @DefaultAggregation: #SUM
 sum( total.tmp_count )    as total,
 @DefaultAggregation: #SUM
 sum( blank.tmp_count )    as blank,
 @DefaultAggregation: #SUM
 sum( error.tmp_count )    as error

and in the second CDS I am adding the fields Total and error as

total + error   as Total_error

and the output is

so if any of the operand (either error/total) is zero my output (Total_error) is coming as Zero.

I tried the below cases also

  1. casting the SUM values in the first CDS to integer.
  2. Casting error and total to integer before adding.
  3. Put a case statement to error to check whether it is Zero, in case of zero it should display only total else display total + error.
  4. In the case statement it is not accepting NULL or '0'.

all these cases i am getting the same output.

Any input will be highly appreciated.


scn1.png (3.6 kB)