Forum Discussion

paulpena7807's avatar
paulpena7807
Frequent Visitor
3 years ago
Solved

Formato Columna Condicional

Quiero crear una medida para condicionar por colores los valores del resultado de la resta del valor anterior con el valor actual de la siguiente formar:

Si supera el valor anterior se formatea en color rojo.

Si es menor al valor anterior se formatea en color verde.

Si es igual al valor anterior se formatea en color amarillo.

 

La tabla se llama registro_csp_mtto y la columna se llama kW.h

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi paulpena7807 

    You can refer to the following example

    Sample data 

     

    Sample measure

    Sum = SUM(registro_csp_mtto[ kW.h])

    1.Create a format measure 

    Format =
    VAR a =
        CALCULATE (
            [Sum],
            OFFSET (
                -1,
                ALLSELECTED ( registro_csp_mtto[ID] ),
                ORDERBY ( [ID], ASC ),
                KEEP
            )
        )
    VAR b = [Sum] - a
    RETURN
        SWITCH ( TRUE (), b > a, "red", b < a, "green", b = a, "yellow" )
    

    Then put it to the conditional formatting

     

    Output

    Best Regards!

    Yolo Zhu

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

     

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi paulpena7807 

    You can refer to the following example

    Sample data 

     

    Sample measure

    Sum = SUM(registro_csp_mtto[ kW.h])

    1.Create a format measure 

    Format =
    VAR a =
        CALCULATE (
            [Sum],
            OFFSET (
                -1,
                ALLSELECTED ( registro_csp_mtto[ID] ),
                ORDERBY ( [ID], ASC ),
                KEEP
            )
        )
    VAR b = [Sum] - a
    RETURN
        SWITCH ( TRUE (), b > a, "red", b < a, "green", b = a, "yellow" )
    

    Then put it to the conditional formatting

     

    Output

    Best Regards!

    Yolo Zhu

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

     

    • paulpena7807's avatar
      paulpena7807
      Frequent Visitor

      Thank you for the slution.

       

      Can you provide me a measure to:

       

      Subtract the current value from the previous value.

       

      Thanks.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi paulpena7807 

        Just modify the format measure to the following 

        Format =
        VAR a =
            CALCULATE (
                [Sum],
                OFFSET (
                    -1,
                    ALLSELECTED ( registro_csp_mtto[ID] ),
                    ORDERBY ( [ID], ASC ),
                    KEEP
                )
            )
        VAR b = a-[Sum]
        RETURN
            SWITCH ( TRUE (), b > a, "red", b < a, "green", b = a, "yellow" )

         

        Best Regards!

        Yolo Zhu

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