Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Calculator - divide by 0 ?

  1. #1
    Join Date
    Sep 2017
    Posts
    27

    Default Calculator - divide by 0 ?

    I m looking for step that would do the math - like division, multiply. I thought about using Calculator step in PDI? I'm seeing an issue with A/B. What happens if B is zero? Is there a work around in that step?
    I am trying to figure out to do something like this -

    If FieldC is zero
    Move Zero to FieldA
    Else
    Field A = Field B/FieldC

    If Calculator step doesn't have capability to go around in situations like this, which steps should I use?

    Thanks,

    Claudia

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    There's a pure dataflow solution to guard against divison-by-zero, but you could use a Java Expression with a ternary operator as well.

    Name:  230860.png
Views: 197
Size:  15.9 KB
    Last edited by marabu; 02-12-2018 at 01:48 AM.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Sep 2017
    Posts
    27

    Default

    okay. Thanks.. I know what you mean by Java Expression as another method of doing this..

    Thank you,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.