LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Math Calculation

    Employee
    Posted 07-22-2014 15:48

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mw9286

    I have two columns of data, month 5 and month 6. I want to use create two new columns, one that shows that dollar change from month 5 to month 6 and one that shows the percentage change.

    How can I accomplish this goal?

    Month 5 Month 6 Dollar Change Percentage Change
    $50.00 $100.00 $50.00 100%
    $100.00 $50.00 $(50.00) -50%
    $75.00 $225.00 $150.00 200%

    Thank you,

    Michael Waxman


  • 2.  RE: Math Calculation

    Employee
    Posted 07-22-2014 19:49

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: xathras

    Michael,

    Assuming your data is tabular like you've given below you could do the following:

    Add a filter node and add the following text:

    Change = 'Month 6' - 'Month 5'
    Percentage_Change = (('Month 6' - 'Month 5') / 'Month 5') * 100

    emit *, Change, Percentage_Change

    I am assuming this is what you want correct?

    Wayne


  • 3.  RE: Math Calculation

    Employee
    Posted 07-24-2014 08:29

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mw9286

    Hello:

    I receive an error when calculating percentages when the equation look like (150/0). How can I get around this error?


  • 4.  RE: Math Calculation

    Employee
    Posted 07-24-2014 08:55

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Hey,

    There is a property that you can change on your server to handle this case, in your site.prop file you can set: ls.brain.node.zeroDivideBehavior=ignore
    Alternately, if you don't want this behavior across the entire server, but just on the node, create a string parameter on the node, giving it any name, but set the runtime property name to ls.brain.node.zeroDivideBehavior and set the value to ignore.

    When you do this, rather than returning an error, the result of a divide by zero will be a constant which displays as "Infinity" when you view the data.

    Tim.


  • 5.  RE: Math Calculation

    Employee
    Posted 07-24-2014 10:43

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mw9286

    Hi Tim:

    Could you provide a node example for just changing the node.

    This is what my node looks like.

    Change = 'JULY' - 'JUNE'
    Percentage_Change = (('JULY' - 'JUNE') / 'JUNE') * 100

    emit *, Change, Percentage_Change


  • 6.  RE: Math Calculation

    Employee
    Posted 07-24-2014 10:52

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    The steps were as mentioned previously:
    • Create a new parameter on the node
      • In the node editor click "Declare Parameters"
      • Create a new parameter
    • Give this any name (I'll call it "ZeroDivideBehavior" for now)
    • Set the Run Time Property Name of the parameter to ls.brain.node.zeroDivideBehavior
      • Ok out of the Parameter Declarations window
    • Locate the "ZeroDivideBehavior" parameter and set the value to "ignore"
    However, in the case of your script above you might just want to handle the case where the "June" amount is zero.
    Then you should work out what result you should really have there - a divide by zero is not a number.

    Also, if you try and perform a further multiplication, you'll get an overflow error.

    So I think really, the best way to handle this would just be to add some special logic for the case that the field 'June' is zero - maybe just set the result to NULL or something?

    Tim.