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.  Checking condition on 2 columns.

    Employee
    Posted 09-22-2016 23:47

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

    Originally posted by: Jagdev

    Hi Experts,

    I need you assistance on the below case. What I am trying to achieve here is checking the value of 2 columns and deriving the out depend on the condition.
    If Columna and columnd is empty then calculate the total value as 'columnb'.double() + 'columnc'.double
    And if there is value in both the column say Columna and columnd then total value is Columna

    if 'Columna'.double() == -1 and 'columnd'.double() == -1 then
    Sample = 'columnb'.double() + 'columnc'.double
    else
    Sample = Columna
    emit *
    override emit Sample.double() as "Total"

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=57e4c3601b6d3d12
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    Columna,columnb,columnc,columnd
    ,1,2,
    ,1,2,
    EOX
    editor:XY=130,130
    end:Static_Data
    
    node:Filter_3
    bretype:core::Filter
    editor:sortkey=57e4c4d243d16375
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    
    emit *
    override emit 'Columna'.double() as Columna
    override emit 'columnb'.double() as columnb
    override emit 'columnc'.double() as columnc
    override emit 'columnd'.double() as columnd
    
    EOX
    editor:XY=210,130
    end:Filter_3
    
    node:Filter
    bretype:core::Filter
    editor:sortkey=57e4c3981acb229c
    input:@40fd2c74167f1ca2/=Filter_3.40fd2c7420761db6
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    if 'Columna'.double() == -1 and 'columnd'.double() == -1 then
    Sample = 'columnb'.double() + 'columnc'.double
    else
    Sample = Columna
    emit *
    override emit Sample.double() as "Total"
    EOX
    editor:XY=310,130
    end:Filter


  • 2.  RE: Checking condition on 2 columns.

    Employee
    Posted 09-23-2016 02:50

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

    Originally posted by: ThomasT

    Hi Jagdev.

    Is it something like this you are looking for?

    node:Filter_2
    bretype:core::Filter
    editor:sortkey=57e4c4d243d16375
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    if '1:Columna' != "" and '1:columnd'!= ""
    then Sample = '1:columnb'.double() + 'columnc'.double()
    else Sample = 'Columna'

    emit *,Sample
    EOX
    editor:XY=280,130
    end:Filter_2

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=57e4c3601b6d3d12
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    Columna,columnb,columnc,columnd
    ,1,2,
    ,1,2,
    EOX
    editor:XY=130,130
    end:Static_Data


  • 3.  RE: Checking condition on 2 columns.

    Employee
    Posted 09-23-2016 03:04

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

    Originally posted by: Jagdev

    Hi Thomas,

    Thanks for looking into it. I am dealing with currency. When I am trying to convert the able logic into double it is throwing an error on the if formula. When I try changing the type to string then the false condition is not working.

    Regards,
    JD


  • 4.  RE: Checking condition on 2 columns.

    Employee
    Posted 09-23-2016 03:31

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

    Originally posted by: mlam

    Hi Jagdev,

    What does your input data look like? When you say that you are dealing with currency, do you mean that there is a currency symbol in the value as well?
    Also, what is the error message that you get?

    Michelle


  • 5.  RE: Checking condition on 2 columns.

    Employee
    Posted 09-23-2016 06:49

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

    Originally posted by: AdamParker

    Jagdev,

    As Michelle asks, it would be best to see a sample of your actual data.

    As to your sample at the top of this thread, why are you checking for "empty" fields with a comparison to -1? If you take a look at the data that feeds into your second filter, the data in 'columna' and 'columnd' are NULL, for which you would want to use the isNull() and isNotNull() functions. If the data in those fields were instead actually empty strings, you would want to compare them to "" (two double-quotes).
    Best practice I have found, if you don't know whether your fields will have a NULL condition or an empty string (or possibly some whitespace that looks empty) is to use this:
    if ('columna'.isNull() or 'columna'.trim() == "") and ('columnd'.isNull() or 'columnd'.trim() == "") then ...
    Basically check both conditions per field. But that only works if your input fields are strings. In your case, just checking the NULL condition will be sufficient.
    if 'columna'.isNull() and 'columnd'.isNull() then ...


  • 6.  RE: Checking condition on 2 columns.

    Employee
    Posted 09-26-2016 04:01

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

    Originally posted by: Jagdev

    Hi All,

    Thanks for your inputs.

    @Adam your Isnull() logic works fine.

    Regards,
    Jagdev