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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerBeeEye
Employee
Employee

Columna condicional basada en el valor de otra tabla con valores coincidentes

Tengo dos tablas:

Servidores

Nombre_de_servidor

Server_OS

Server_Latest_Patch

Server_1

Windows Server 2016

KB123

Server_2

Windows Server 2019

KB789

Server_3

Windows Server 2016

KB456

Critical_Patch

el

KB_ID

Windows Server 2016

KB456

Windows Server 2019

KB789

Me gustaría tener la columna condicional así

Servidores

Nombre_de_servidor

Server_OS

Server_Latest_Patch

Critical_Patch_Installed

Server_1

Windows Server 2016

KB123

No

Server_2

Windows Server 2019

KB789

Server_3

Windows Server 2016

KB456

La lógica es:

  1. Para cada fila de la tabla Servidores:
    1. Si existe una coincidencia entre los servidores[Server_OS] y Critical_Patch[OS]
      1. Si Servidores[Server_Latest_Patch] es igual a Critical_Patch[KB_ID]
        1. Establecer servidores[Critical_Patch_Installed] en "Sí"
        2. De lo contrario, establezca Servidores[Critical_Patch_Installed] en "No"

¿Cuál es la mejor manera de hacerlo?

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hola @PowerBeeEye ,

Puede crear una columna calculada utilizando la siguiente fórmula dax:

Critical_Patch_Installed =
IF (
    'Servers'[Server_OS] IN DISTINCT ( 'Critical_Patch'[OS] ),
    IF (
        'Servers'[Server_Latest_Patch] IN DISTINCT ( 'Critical_Patch'[KD_ID] ),
        "Yes",
        "No"
    ),
    "No"
)

result.png

Best Looks,
Yingjie Li

Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hola @PowerBeeEye ,

Puede crear una columna calculada utilizando la siguiente fórmula dax:

Critical_Patch_Installed =
IF (
    'Servers'[Server_OS] IN DISTINCT ( 'Critical_Patch'[OS] ),
    IF (
        'Servers'[Server_Latest_Patch] IN DISTINCT ( 'Critical_Patch'[KD_ID] ),
        "Yes",
        "No"
    ),
    "No"
)

result.png

Best Looks,
Yingjie Li

Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

amitchandak
Super User
Super User

@PowerBeeEye , Probar nueva columna en la tabla Servidores

if(isblank(countx(filter(Critical_Patch,Servers[Server_OS] ?Critical_Patch[OS]),Critical_Patch[KB_ID])),"No","Sí")

cuando Critical_Patch a los servidores es 1 a M realtion

if(isblank(related(Critical_Patch[KB_ID])),"No","Yes")

gracias, @amitchandak , pero no veo dónde se está haciendo la coincidencia de las columnas Critical_Patch[OS] y Servidores[Server_OS].

Para decir de nuevo, esto es lo que estoy tratando de hacer:

  1. Cree una columna condicional denominada Critical_Patch_Installed en la tabla Servidores
  2. Para cada fila de la tabla Servidores:
    1. Si existe una coincidencia entre los servidores[Server_OS] y Critical_Patch[OS]
      1. Si Servidores[Server_Latest_Patch] es igual a Critical_Patch[KB_ID]
        1. Establecer servidores[Critical_Patch_Installed] en "Sí"
        2. De lo contrario, establezca Servidores[Critical_Patch_Installed] en "No"

¡Gracias!

Hola @PowerBeeEye,

Puede hacerlo en Power Query combinando la tabla Server y las tablas de revisiones críticas en las claves de combinación entre las dos tablas y una columna personalizada M Code Below

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk4tKkstijdU0lE6tEABjIDM8My8lPzyYgWIrIKRgaEZqgJvJ0MjY6VYHbgBRoQMsEQ3wNzCEtkAY5JdYGJqphQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Server_Name = _t, #"(blank)" = _t, Server_OS = _t, #"(blank).1" = _t, Server_Latest_Patch = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Server_Name", type text}, {"(blank)", type text}, {"Server_OS", type text}, {"(blank).1", type text}, {"Server_Latest_Patch", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"(blank).1", "(blank)"}),
    #"Merged Queries" = Table.NestedJoin(#"Removed Columns", {"Server_OS", "Server_Latest_Patch"}, Critical_Patch, {"OS", "KB_ID"}, "Critical_Patch", JoinKind.LeftOuter),
    #"Expanded Critical_Patch" = Table.ExpandTableColumn(#"Merged Queries", "Critical_Patch", {"KB_ID"}, {"KB_ID"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Critical_Patch", "Critical Patch Installed", each if [KB_ID] <> null then "Yes" else "No")
in
    #"Added Custom"

también puede crear una columna personalizada en la tabla de servidores mediante DAX

Patched = 
var patched = LOOKUPVALUE(Critical_Patch[KB_ID], Critical_Patch[KB_ID], 'Servers'[Server_Latest_Patch], Critical_Patch[OS], [Server_OS])
return if(patched <> BLANK(), "Yes", "No")


Espero que esto ayude,
Richard


¿He respondido a tu pregunta? ¡Marca mi puesto como una solución!
¿Mis respuestas ayudaron a llegar a una solución? Dale un kudos haciendo clic en Thumbs Up!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.