Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: [javascript] Count Varaibles

  1. #1
    Join Date
    Jun 2009
    Posts
    20

    Default [javascript] Count Varaibles

    Hi, i have create a trasformation such as count a number of rows where row value at 'xxxxxxx' i have used javascript step, previous step is table input but the value return always value 16 .

    The code javascript is this:

    [javascript]
    //Main
    var num_Esito_OCC=0;
    var num_Esito_ABF=0;
    var num_Esito_LNR=0;




    for (var i=0;i<getInputRowMeta().size();i++) { //loop through the actual row

    // Grab the metadata for this value
    if(CodiFisc.getString()==null){

    CodiFisc.setValue("0000000000000000");

    }


    if(CodiFisc.getString()=='0000000488410010'){

    num_Esito_OCC=num_Esito_OCC+6;
    num_Esito_ABF++
    num_Esito_LNR++;
    }




    if(CodiFisc.getString()=='0000003562770481'){

    num_Esito_OCC=1;

    }



    }

    [/javascript]

  2. #2
    Join Date
    Jun 2009
    Posts
    20

    Default

    Help me!!

  3. #3
    Join Date
    Jun 2009
    Posts
    20

    Default

    I have changed but, now print 17;

    num_Esito_OCC.setValue(num_Esito_OCC.getNumber()+1);

    return 17, the row is 43 . Why ?

  4. #4
    Join Date
    Jul 2007
    Posts
    247

    Default

    Don't compare strings using the == operator, it won't work properly. Always use equals() (e.g. CodiFisc.getString().equals("0000000488410010") to compare them.

    For the rest... I have actually no idea why you want to loop through the acual row since your are only refering to one specific field (CodiFisc) in the row, but that's up to you ...


    HTH,
    Ben

  5. #5
    Join Date
    Jun 2009
    Posts
    20

    Default

    It's is not possible count a variable in javascript ??

  6. #6
    Join Date
    Jul 2007
    Posts
    247

    Default

    Sure it is, why not? All I said, I doubt your code, that's all

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.