Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

sum columm with condition

Hi guys,

I have trouble do to a task here

I do this


What i need

when [CodUser] be:

280 ||
621 ||
928 ||
512 ||
284
I want return the columm [jornadaMin] + 23,  if another number i want return [JornadaMin] only

I do this, but don´t work

 

Look the return i have sum + 23 in every line

Thank you

 

  • Hi, Anonymous 

     

    You can try the following methods.

    JornadaMin2 = 
    IF (
        [CodUser] IN ( { 280, 621, 928, 512, 284 } ),
        [JornadaMin] + 23,
        IF (
            [CodUser] IN ( { 1772, 1226, 295, 975 } ),
            [JornadaMin] + 48,
            [JornadaMin]
        )
    )
    JornadaMin3 = 
    VAR n2 = [JornadaMin] + 23
    VAR adm = [JornadaMin] + 48
    VAR n = [JornadaMin]
    RETURN
        IF (
            [CodUser] IN ( { 280, 621, 928, 512, 284 } ),
            n2,
            IF ( [CodUser] IN ( { 1772, 1226, 295, 975 } ), adm, n )
        )

    Both formulas can get the results you want.

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous what are these measures/columns? You have to be more specific?

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, Anonymous 

     

    You can try the following methods.

    JornadaMin2 = 
    IF (
        [CodUser] IN ( { 280, 621, 928, 512, 284 } ),
        [JornadaMin] + 23,
        IF (
            [CodUser] IN ( { 1772, 1226, 295, 975 } ),
            [JornadaMin] + 48,
            [JornadaMin]
        )
    )
    JornadaMin3 = 
    VAR n2 = [JornadaMin] + 23
    VAR adm = [JornadaMin] + 48
    VAR n = [JornadaMin]
    RETURN
        IF (
            [CodUser] IN ( { 280, 621, 928, 512, 284 } ),
            n2,
            IF ( [CodUser] IN ( { 1772, 1226, 295, 975 } ), adm, n )
        )

    Both formulas can get the results you want.

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.