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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Declaración compleja de si entonces

No estoy seguro de cómo crear esta instrucción IF Then, cualquier ayuda sería apreciada. Tengo dos variables que necesitan ser analizadas y una nueva columna creada.

Desea saber si se puede hacer mediante funciones DAX o el generador if then en el modo de consulta.

Fecha de la Fiscalía, Fecha de la Corte.

Si ambas variables están en blanco , Desconocido

Si la Fiscalía está en blanco y el tribunal tiene un valor de "Tribunal"

Si el Tribunal está en blanco y la Fiscalía tiene un valor "Prosec"

Si ambas variables tienen un valor " Court" o "Prosec" lo que tenga la fecha más reciente.

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hola @FLCrime

hay 2 opciones:

1. DAX usando SWITCH()

Column = SWITCH(TRUE(),
ISBLANK([Prosecution Date]) && ISBLANK([Court Date]), "Unknown",
ISBLANK([Prosecution Date]) && NOT(ISBLANK([Court Date])), "Court",
NOT(ISBLANK([Prosecution Date])) && ISBLANK([Court Date]), "Prosec",
[Prosecution Date]>[Court Date], "Prosec",
"Court"
)

2. Power QUery Custom Column

= if [Prosecution Date] = null and [Court Date] = null then "Unknown"
else if [Prosecution Date] = null and [Court Date] <> null then "Court"
else if [Prosecution Date] <> null and [Court Date] = null then "Prosec"
else if [Prosecution Date] > [Court Date] then "Prosec"
else "Court"


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

Pruebe una nueva columna como

Switch( true(),
isblank([Prosecution Date]) && isblank([Court Date]) ,"Unknown",
isblank([Prosecution Date]) && not(isblank([Court Date])),"Court",
not(isblank([Prosecution Date])) && (isblank([Court Date])),"Prosec",
max([Prosecution Date],[Court Date])
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
az38
Community Champion
Community Champion

Hola @FLCrime

hay 2 opciones:

1. DAX usando SWITCH()

Column = SWITCH(TRUE(),
ISBLANK([Prosecution Date]) && ISBLANK([Court Date]), "Unknown",
ISBLANK([Prosecution Date]) && NOT(ISBLANK([Court Date])), "Court",
NOT(ISBLANK([Prosecution Date])) && ISBLANK([Court Date]), "Prosec",
[Prosecution Date]>[Court Date], "Prosec",
"Court"
)

2. Power QUery Custom Column

= if [Prosecution Date] = null and [Court Date] = null then "Unknown"
else if [Prosecution Date] = null and [Court Date] <> null then "Court"
else if [Prosecution Date] <> null and [Court Date] = null then "Prosec"
else if [Prosecution Date] > [Court Date] then "Prosec"
else "Court"


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Soy bastante nuevo en Power Bi ¿"[]" indica una tabla? Todas mis variables son columnas en una tabla.

@FLCrime -

La documentación muestra una buena explicación de la sintaxis. https://docs.microsoft.com/en-us/dax/dax-syntax-reference.

image.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



az38
Community Champion
Community Champion

@FLCrime

[] es un nombre de columna dentro de tu mesa.

Tabla[Columna] - sintaxis completa


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

¡Muchas gracias! Esto ha sido muy útil.

¿Sabe cómo puedo usar esta nueva columna en una instrucción if then, pero usando una función DAX en su lugar? Como si el tribunal fuera de la corte, entonces [Declaración del Tribunal] si - Prosec entonces [Declaración de Prosec], de lo contrario desconocido.

Haría el si entonces en modo de consulta de energía, pero trabajando desde casa perdí el acceso al servidor y no puedo actualizar los datos. Así que no hay una consulta de energía para mí hoy.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.