Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Cumulative sum in java script using array

  1. #1

    Default Cumulative sum in java script using array

    Hi All,

    I am stuck with creating the multidimensional array in 'Modified javascript' step
    • I have the input like
      ID Product Sale
      1 Fruits 10
      2 Biscuit 20
      1 Fruits 12
      3 Beer 29

    I am trying to create the javascript to add those columns values in multidimensional array and sort based on 'Product', then will try to sum the sales based on 'Product'.
    Expected Output: id 1-> Fruits -sales(10+12)=22
    Can you please help to solve this using javascript array or map?
    I have done this using kettle steps like 'groupby' but need to solve this by javascript.

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

    Default

    You are trying to write your first JavaScript lines ever and need an introduction to the language?

    This could be the wrong forum.
    So long, and thanks for all the fish.

  3. #3

    Default

    Hello,

    I think this problem is related to Kettle java script step and I thought this is the correct forum for that.
    I need to solve this issue in kettle 'Modified java script' steps.

  4. #4
    Join Date
    Apr 2008
    Posts
    4,690

    Default

    Quote Originally Posted by tushartajane18@gmail.com View Post
    I have done this using kettle steps like 'groupby' but need to solve this by javascript.
    Could you explain why you need to solve this in Javascript? The GroupBy is a more efficient step.

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.