KAPOW

Would you like to react to this message? Create an account in a few clicks or log in to continue.
KAPOW

Welcome to the Kapow forum. Here you can get help, use your skills to help others and enjoy hanging out in the company of other Kapow Robot Developers.


2 posters

    How to SUM extracted values

    avatar
    cmorris


    Posts : 14
    Points : 2565
    Join date : 2017-05-17

    How to SUM extracted values Empty How to SUM extracted values

    Post by cmorris Thu Mar 22, 2018 11:07 pm

    Hi,

    Does anyone know how to sum up extracted values, so that I would have a total figure in my variable?  I have a CSV file I am looping over, I want to extract each value then come up with the total.  Any ideas welcome, as I am a bit stuck!

    Thanks in advance.
    jking
    jking


    Posts : 103
    Points : 3851
    Join date : 2014-03-01
    Location : USA

    How to SUM extracted values Empty Re: How to SUM extracted values

    Post by jking Fri Mar 23, 2018 3:57 am

    You will need 2 variables.  One variable for the Sum, and one variable for the Extracted Value.  Note that the variable for the Sum must be Global.
    Extract your value from the CSV.  You next step would be an Assign Variable step using an Expression.
    Expression value would be SumVariable+ExtractedValue.  Note that the order is critical.
    When you Execute the Assign Variable Step, the SumVariable will be the product of the SumVariable + Extracted Value.
    Initially the value of the SumVariable will be blank.  SumVariable+ExtractedValue will result in a value of the ExtractedValue.
    Extract your next value and add another Assign Variable Step with the same expression SumVariable+ExtractedValue, the SumVariable will now have the product of both of the extracted values.  You can continue this pattern as often as necessary to sum all values.

    An alternate method would be to create a Type that contains variables that match your CSV, and then Create a Database Table based on the Type.
    Extract each value into the Type and use a StoreInDatabase step.  
    Once you have finished looping your CSV, you can add a QueryDatabase step and write an SQL statement to sum the individual values.
    avatar
    cmorris


    Posts : 14
    Points : 2565
    Join date : 2017-05-17

    How to SUM extracted values Empty Re: How to SUM extracted values

    Post by cmorris Fri Mar 23, 2018 7:31 pm

    That's perfect!  Thank you very much for that explanation, exactly what I was  after.
    jking
    jking


    Posts : 103
    Points : 3851
    Join date : 2014-03-01
    Location : USA

    How to SUM extracted values Empty Re: How to SUM extracted values

    Post by jking Fri Mar 23, 2018 7:47 pm

    Happy to help.

    Sponsored content


    How to SUM extracted values Empty Re: How to SUM extracted values

    Post by Sponsored content


      Current date/time is Sun Apr 28, 2024 4:07 am