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
Anonymous
Not applicable

Fecha y hora Columna personalizada If/Then Sintaxis

Nuevo en Power BI y necesito crear sintaxis para que una columna personalizada incluya:

DIA DE SEMANA SOLO como Viernes y TIEMPO LLEGA SOLAMENTE como después de las 5:00:00pm, DIA DE SEMANA SOLO como Sábado - sin restricciones de tiempo, y DIA DE SEMANA SOLO como Domingo - sin restricción de tiempo.

Viernes después de las 5:00:00pm se codificaría como 1_Fri

Sábado como 2_Sat

Domingo como 3_Sun

Todo lo demás siendo codificado como 0

Parece que no puedo hacer que mi sintaxis funcione correctamente. Cualquier ayuda sería muy apreciada!

alexandriaIDEA_0-1593792831003.png

4 REPLIES 4
ryan_mayu
Super User
Super User

@alexandriaIDEA

puede intentar usar DAX para crear una columna

Column = if(right('Table (2)'[DAY OF WEEK ONLY],3)="Fri" && 'Table (2)'[TIME ARRIVED ONLY]>TIME(17,0,0) ,"1_Fri",if(RIGHT('Table (2)'[DAY OF WEEK ONLY],3)="Sat","2_Sat",if(RIGHT('Table (2)'[DAY OF WEEK ONLY],3)="Sun","3_Sun","0")))

1.PNG





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

Proud to be a Super User!




Anonymous
Not applicable

¡Oye, @ryan_mayu!

¿Hay alguna manera de hacerlo a través de Query en lugar de a través de DAX? Realmente estoy tratando de obtener una mejor retención en las declaraciones if/then en Query y no entiendo por qué sigo recibiendo errores ya que sé exactamente lo que necesito y de dónde vienen las variables. Gracias, sin importar!!!!

@alexandriaIDEA

No soy bueno en M, tal vez puedas intentarlo

if Text.End([DAY OF WEEK ONLY],3)="Fri" and [TIME ARRIVED ONLY]>#time(17,0,0) then "1_Fri" else if Text.End([DAY OF WEEK ONLY],3)="Sat" then "2_Sat" else if Text.End([DAY OF WEEK ONLY],3)="Sun" then "3_Sun" else 0

1.PNG





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

Proud to be a Super User!




Anonymous
Not applicable

¡Woohoo! @ryan_mayulo funcionó perfectamente! ¡Muchas gracias, eres mi héroe!

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.