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.  If Statement

    Employee
    Posted 12-11-2017 08:13

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

    Originally posted by: jchartrand

    Morning,

    I'm sure I've over complicated what should be a simple procedure in Lavastorm.

    Essentially I have the following rules that need to be applied to an existing data set. If those rules are met, I want my new column to be populated with a specific string.

    i.e.

    if 'Brand' = "X" and 'Category' = null then NewCategory = "Y" else NewCategory = 'Category'

    Now here is where I'm sure I've over complicated this.

    I want to repeat that rule with several other inputs, and have them all populate the same single column output for NewCategory. I've worked around it in a convoluted way so I thought I'd ask the experts for a better solution.

    if 'Brand' = "X" and 'Category' = null then NewCategory = "Y" else NewCategory = 'Category'
    if 'Brand' = "A" and 'Category' = null then NewCategory = "B" else NewCategory = 'Category'
    if 'Brand' = "B" and 'Category' = null then NewCategory = "Y" else NewCategory = 'Category'
    if 'Brand' = "C" and 'Category' = null then NewCategory = "D" else NewCategory = 'Category'


    Thanks!
    J


  • 2.  RE: If Statement

    Employee
    Posted 12-11-2017 08:24

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

    Originally posted by: jmok

    Hi jchartrand,

    Thanks for sharing this on the forum. Please give the below a try

    NewCategory = if 'Brand' == "X" and 'Category'.isNull() then "Y"
    else if 'Brand' == "A" and 'Category'.isNull() then "B"
    else if 'Brand' == "B" and 'Category'.isNull() then "Y"
    else if 'Brand' == "C" and 'Category'.isNull() then "D"
    else "NULL"

    emit *, NewCategory


  • 3.  RE: If Statement

    Employee
    Posted 12-11-2017 08:37

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

    Originally posted by: jchartrand

    Originally posted by: jmok
    					

    Hi jchartrand,

    Thanks for sharing this on the forum. Please give the below a try

    NewCategory = if 'Brand' == "X" and 'Category'.isNull() then "Y"
    else if 'Brand' == "A" and 'Category'.isNull() then "B"
    else if 'Brand' == "B" and 'Category'.isNull() then "Y"
    else if 'Brand' == "C" and 'Category'.isNull() then "D"
    else "NULL"

    emit *, NewCategory
    Yup... definitely made that A LOT harder than it hard to be.

    Thanks for the quick response.

    Cheers,
    J


  • 4.  RE: If Statement

    Employee
    Posted 12-11-2017 08:40

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

    Originally posted by: jmok

    Glad it works J, let us know if you have any other questions