Forum Discussion

MMPagola's avatar
MMPagola
Icon for Helper II rankHelper II
5 years ago
Solved

Funcion suma con IN

Me encuentro ante esta dificultad:

En la siguiente fórmula, quiero indicar que el campo DepositoDestino_id es el 3 o que el campo está en blanco.

PP ALTA 0 y 3 = CALCULATE(SUM(Movimientos[Cantidad]), FILTER(Movimientos, Movimientos[Alta] = TRUE), FILTER(Movimientos, Movimientos[DepositoDestino_id] IN {0,3}))

No funciona. SI hago 2 fórmulas, sí funciona:

PP ALTA 3 = CALCULATE(SUM(Movimientos[Cantidad]), FILTER(Movimientos, Movimientos[Alta] = TRUE), FILTER(Movimientos, Movimientos[DepositoDestino_id] = 3))

PP ALTA 0 = CALCULATE(SUM(Movimientos[Cantidad]), FILTER(Movimientos, Movimientos[Alta] = TRUE), FILTER(Movimientos, Movimientos[DepositoDestino_id] = 0))

 

Quisiera saber cuál es la forma de tener el total en una sola fórmula y no tener que hacerlo en 2. Muchas gracias.

  • Anonymous's avatar
    Anonymous
    5 years ago

    HI MMPagola,

    I modify your formula to use AND, OR logic function to link two conditions, you can try to use the below formula if helps:

    PP ALTA 0 y 3 =
    CALCULATE (
        SUM ( Movimientos[Cantidad] ),
        FILTER (
            Movimientos,
            AND (
                Movimientos[Alta] = TRUE,
                OR ( Movimientos[DepositoDestino_id] = 0, Movimientos[DepositoDestino_id] = 3 )
            )
        )
    )

    If the above formula not works, can you please some dummy data to test? It should help us clarify your scenario and test to coding formula.

    How to Get Your Question Answered Quickly  

    Regards,

    Xiaoxin Sheng

3 Replies

  • MMPagola , Try like and check

     

    PP ALTA 0 y 3 = CALCULATE(SUM(Movimientos[Cantidad]), FILTER(Movimientos, Movimientos[Alta] = true() && Movimientos[DepositoDestino_id] IN {0,3}))

    • MMPagola's avatar
      MMPagola
      Icon for Helper II rankHelper II

      Hola, gracias por tu ayuda pero no funciona. Asi, me toma solamente las cantidades del depósito 3

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI MMPagola,

    I modify your formula to use AND, OR logic function to link two conditions, you can try to use the below formula if helps:

    PP ALTA 0 y 3 =
    CALCULATE (
        SUM ( Movimientos[Cantidad] ),
        FILTER (
            Movimientos,
            AND (
                Movimientos[Alta] = TRUE,
                OR ( Movimientos[DepositoDestino_id] = 0, Movimientos[DepositoDestino_id] = 3 )
            )
        )
    )

    If the above formula not works, can you please some dummy data to test? It should help us clarify your scenario and test to coding formula.

    How to Get Your Question Answered Quickly  

    Regards,

    Xiaoxin Sheng