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.  SumIf

    Employee
    Posted 05-28-2015 00:38

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

    Originally posted by: lauraw_21

    Hi

    Hope someone can help, I am in early stages of Lava and yet to go on the training (next week )

    I am using an Agg Ex node but would like to perform what in excel would be a "sumif", effectively asking, if one column = this, then sum this...

    Hope that makes sense, please could someone help?

    Thanks
    Laura


  • 2.  RE: SumIf

    Employee
    Posted 05-28-2015 06:56

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

    Originally posted by: stonysmith

    That is easy. You need to set an initial value for the variable, and then just use IF to condition the sum.


    if firstInGroup then Total=0.0
    if 'MyColumnOne' == "D" then Total=Total+'MyColumnTwo'
    emit Total

    ===
    you can even do it across multiple columns at once:

    if firstInGroup then { TotalC=0.0 TotalD = 0.0 }
    if 'MyColumnOne' == "C" then TotalC=TotalC +'MyColumnTwo'
    if 'MyColumnOne' == "D" then TotalD=TotalD +'MyColumnTwo'
    emit TotalC,TotalD