Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Syndicate_Admin
Administrator
Administrator

Formato de celda en matriz basado en fila/columna: error al asignar la medida al formato condicional

Me gustaría asignar formato condicional a una matriz en función de los valores de fila/columna.

jstanley1017_0-1733175820567.png

He creado una medida llamada color para usar en este formato condicional.

color =
Var row_selection = Int(DERECHA(SELECTEDVALUE(Interconexión[Nivel],1)))
VAR column_selection = Int(DERECHA(SELECTEDVALUE(Nada[Resistencia],1)))
Devolución
SI(Y(row_selection="Nivel 1",column_selection="AA"),"Verde",
SI(Y(row_selection="Nivel 2",column_selection="AA"),"Verde",
SI(Y(row_selection="Nivel 3",column_selection="AA"),"Verde",
SI(Y(row_selection="Nivel 4",column_selection="AA"),"Verde",
SI(Y(row_selection="Nivel 5",column_selection="AA"),"Verde",
SI(Y(row_selection="N/A - Sin nivel",column_selection="AA"),"Verde",
SI(Y(row_selection="Nivel 1",column_selection="RR"),"Verde",
SI(Y(row_selection="Nivel 2",column_selection="RR"),"Verde",
SI(Y(row_selection="Nivel 3",column_selection="RR"),"Verde",
SI(Y(row_selection="Nivel 4",column_selection="RR"),"Verde",
SI(Y(row_selection="Nivel 5",column_selection="RR"),"Verde",
SI(Y(row_selection="N/A - Sin nivel",column_selection="RR"),"Verde",
SI(Y(row_selection="Nivel 1",column_selection="COMO"),"Amarillo",
SI(Y(row_selection="Nivel 2",column_selection="COMO"),"Amarillo",
SI(Y(row_selection="Nivel 3",column_selection="COMO"),"#CCFF66",
SI(Y(row_selection="Nivel 4",column_selection="COMO"),"#CCFF66",
SI(Y(row_selection="Nivel 5",column_selection="COMO"),"#CCFF66",
SI(Y(row_selection="N/A - Sin nivel",column_selection="COMO"),"#CCFF66",
SI(Y(row_selection="Nivel 1",column_selection="AP"),"Amarillo",
SI(Y(row_selection="Nivel 2",column_selection="AP"),"Amarillo",
SI(Y(row_selection="Nivel 3",column_selection="AP"),"Amarillo",
SI(Y(row_selection="Nivel 4",column_selection="AP"),"#CCFF66",
SI(Y(row_selection="Nivel 5",column_selection="AP"),"#CCFF66",
SI(Y(row_selection="N/A - Sin nivel",column_selection="AP"),"#CCFF66",
SI(Y(row_selection="Nivel 1",column_selection="ND"),"Rojo",
SI(Y(row_selection="Nivel 2",column_selection="ND"),"Rojo",
SI(Y(row_selection="Nivel 3",column_selection="ND"),"Rojo",
SI(Y(row_selection="Nivel 4",column_selection="ND"),"Rojo",
SI(Y(row_selection="Nivel 5",column_selection="ND"),"Gris",
SI(Y(row_selection="N/A - Sin nivel",column_selection="ND"),"#FFFFFF",
"#FFFFFF"
))))))))))))))))))))))))))))))
Cuando intento ingresar esto en el formato condicional para el color de fondo, veo un cuadro rojo después de seleccionar la medida de color.
jstanley1017_1-1733175947795.png

Dado que copié el concepto de otro que encontré, probablemente me perdí algo importante aquí. Cualquier ayuda es apreciada.

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Hola @jstanley1017 ,

Consulte los siguientes pasos.

La medida es la siguiente.

color = 
 var row_selection = (SELECTEDVALUE(Tiering[Tier],1))
 VAR column_selection = SELECTEDVALUE(Res[Resiliency],1)
RETURN
SWITCH(TRUE(),
    column_selection IN {"AA","RR"},"Green",
    column_selection="AS",IF(row_selection IN{"Tier 1","Tier 2"},"Yellow","#CCFF66"),
    column_selection="AP",IF(row_selection IN{"Tier 1","Tier 2"},"Yellow","#CCFF66"),
    column_selection="ND",IF(row_selection IN {"Tier 1","Tier 2","Tier 3", "Tier 4" },"Red",
                                IF(row_selection = "Tier 5","Gray","#FFFFFF")
                                ),
    "#FFFFFF"
)

Utilice la medida como formato de fondo para los valores de la matriz. Y el resultado final es el siguiente.

vdengllimsft_0-1733195160584.png


Consulte el pbix adjunto como referencia.

Saludos
Dengliang Li

Si esta publicación ayuda, considere Acéptalo como la solución para ayudar a los demás miembros a encontrarlo más rápidamente.

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

Hola @jstanley1017 .

Hice algunos cambios en su fórmula, verifique si funciona correctamente.
Notas futuras:
- Compare directamente los valores de texto como "Nivel 1", "Nivel 2", etc. en lugar de extraer el último carácter.
- La función de interruptor hace que la lógica sea más legible y eficiente para el futuro.

color =
VAR row_selection = SELECTEDVALUE(Tiering[Tier])
VAR column_selection = SELECTEDVALUE(Res[Resiliency])
RETURN
    SWITCH(
        TRUE(),
        AND(row_selection = "Tier 1", column_selection = "AA"), "Green",
        AND(row_selection = "Tier 2", column_selection = "AA"), "Green",
        AND(row_selection = "Tier 3", column_selection = "AA"), "Green",
        AND(row_selection = "Tier 4", column_selection = "AA"), "Green",
        AND(row_selection = "Tier 5", column_selection = "AA"), "Green",
        AND(row_selection = "N/A - No Tier", column_selection = "AA"), "Green",
        AND(row_selection = "Tier 1", column_selection = "RR"), "Green",
        AND(row_selection = "Tier 2", column_selection = "RR"), "Green",
        AND(row_selection = "Tier 3", column_selection = "RR"), "Green",
        AND(row_selection = "Tier 4", column_selection = "RR"), "Green",
        AND(row_selection = "Tier 5", column_selection = "RR"), "Green",
        AND(row_selection = "N/A - No Tier", column_selection = "RR"), "Green",
        AND(row_selection = "Tier 1", column_selection = "AS"), "Yellow",
        AND(row_selection = "Tier 2", column_selection = "AS"), "Yellow",
        AND(row_selection = "Tier 3", column_selection = "AS"), "#CCFF66",
        AND(row_selection = "Tier 4", column_selection = "AS"), "#CCFF66",
        AND(row_selection = "Tier 5", column_selection = "AS"), "#CCFF66",
        AND(row_selection = "N/A - No Tier", column_selection = "AS"), "#CCFF66",
        AND(row_selection = "Tier 1", column_selection = "AP"), "Yellow",
        AND(row_selection = "Tier 2", column_selection = "AP"), "Yellow",
        AND(row_selection = "Tier 3", column_selection = "AP"), "Yellow",
        AND(row_selection = "Tier 4", column_selection = "AP"), "#CCFF66",
        AND(row_selection = "Tier 5", column_selection = "AP"), "#CCFF66",
        AND(row_selection = "N/A - No Tier", column_selection = "AP"), "#CCFF66",
        AND(row_selection = "Tier 1", column_selection = "ND"), "Red",
        AND(row_selection = "Tier 2", column_selection = "ND"), "Red",
        AND(row_selection = "Tier 3", column_selection = "ND"), "Red",
        AND(row_selection = "Tier 4", column_selection = "ND"), "Red",
        AND(row_selection = "Tier 5", column_selection = "ND"), "Gray",
        AND(row_selection = "N/A - No Tier", column_selection = "ND"), "#FFFFFF",
        "#FFFFFF" -- Default value
    )


Por favor, marque la pregunta resuelta cuando haya terminado y considere felicitar si las publicaciones son útiles.

Bien
Luis

Syndicate_Admin
Administrator
Administrator

¡Gracias Luis!

Syndicate_Admin
Administrator
Administrator

Hola @jstanley1017 ,

Consulte los siguientes pasos.

La medida es la siguiente.

color = 
 var row_selection = (SELECTEDVALUE(Tiering[Tier],1))
 VAR column_selection = SELECTEDVALUE(Res[Resiliency],1)
RETURN
SWITCH(TRUE(),
    column_selection IN {"AA","RR"},"Green",
    column_selection="AS",IF(row_selection IN{"Tier 1","Tier 2"},"Yellow","#CCFF66"),
    column_selection="AP",IF(row_selection IN{"Tier 1","Tier 2"},"Yellow","#CCFF66"),
    column_selection="ND",IF(row_selection IN {"Tier 1","Tier 2","Tier 3", "Tier 4" },"Red",
                                IF(row_selection = "Tier 5","Gray","#FFFFFF")
                                ),
    "#FFFFFF"
)

Utilice la medida como formato de fondo para los valores de la matriz. Y el resultado final es el siguiente.

vdengllimsft_0-1733195160584.png


Consulte el pbix adjunto como referencia.

Saludos
Dengliang Li

Si esta publicación ayuda, considere Acéptalo como la solución para ayudar a los demás miembros a encontrarlo más rápidamente.

Syndicate_Admin
Administrator
Administrator

Está realizando conversiones de enteros en valores de texto.

La lógica también se puede simplificar mediante el uso de rangos de validez en lugar de especificar cada una de las combinaciones.

Proporcione datos de muestra que cubran su problema o pregunta por completo, en un formato utilizable (no como una captura de pantalla).
No incluyas información confidencial. No incluya nada que no esté relacionado con el problema o la pregunta.
Muestre el resultado esperado en función de los datos de muestra que proporcionó.

¿Necesitas ayuda para subir datos? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
¿Quieres respuestas más rápidas? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors
Top Kudoed Authors