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

Formato de fecha del texto

Tengo una columna que viene como texto que se supone que es una fecha. Quiero convertir ese texto a la fecha, pero cuando utilizo Format(Date," ? / ) y luego ir a cambiarlo tipo dice format() no es capaz de convertir texto a la fecha.

Ejemplo: 81015 a 8/10/15:

image.png

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

@Coglizer

Sí.

Tratar

Column = 
IF(ISBLANK([DATE]), BLANK(),
DATE(VALUE(RIGHT([DATE], 2)) + 2000, VALUE(LEFT([DATE], LEN([DATE])-4)), VALUE(MID([DATE],LEN([DATE])-3,2)))
)

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

View solution in original post

10 REPLIES 10
mahoneypat
Employee
Employee

Puede analizar esto con funciones de texto DAX, pero esta es una gran aplicación de Column from Examples en el editor de consultas de energía. Por favor, consulte este enlace - https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-add-column-from-example

Lo usé en datos similares y creó automáticamente una columna personalizada con esta expresión M

Text.Combine('Text.Reverse(Text.Middle(Text.Reverse(Text.From([Date], "en-US")), 4)), "/", Text.Reverse(Text.Middle(Text.Reverse(Text.Reverse([Date], "en-US")), 2, 2)), "/20", Text.End(Text.From([Date], "en-US")

Si todavía quieres hacerlo con DAX, aquí hay una manera de hacerlo

NewDateColumn á Left('Date'[Date],LEN('Date'[Date])-4)&"/"&Left(Right('Date'[Date],4),2)&"/"&RIGHT('Date'[Date],2)

Si esto funciona para usted, márquelo como la solución. Los elogios también son apreciados. Por favor, avísame si no.

saludos

palmadita





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Gracias @mahoneypat por la información perspicaz!

Cuando intenté usar la instrucción DAX, obtengo este error.

image.png

az38
Community Champion
Community Champion

@Coglizer

crear una columna calculada

Column = DATE(VALUE(RIGHT([DATE], 2)) + 2000, VALUE(LEFT([DATE], LEN([DATE])-4)), VALUE(MID([DATE],LEN([DATE])-3,2)))

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

@az38 Gracias por la información, pero obtengo "Un argumento de la función 'LEFT' tiene el tipo de datos incorrecto o tiene un valor/" error no válido.

az38
Community Champion
Community Champion

@Coglizer

¿está seguro de que copió el ejemplo de declaración como sugerí? funciona según corresponda para mí, revisé dos veces


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

@az38

Sí, he comprobado que he copiado correctamente.

image.png

az38
Community Champion
Community Champion

@Coglizer

¿tiene valores con una longitud de 4 dígitos?


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

@az38

El más grande que tengo es de 6 dígitos y el más pequeño que tengo es de 5 dígitos. ¿Revisé mi conjunto de datos y parece que podría tener algunos espacios en blanco si eso afectaría?

az38
Community Champion
Community Champion

@Coglizer

Sí.

Tratar

Column = 
IF(ISBLANK([DATE]), BLANK(),
DATE(VALUE(RIGHT([DATE], 2)) + 2000, VALUE(LEFT([DATE], LEN([DATE])-4)), VALUE(MID([DATE],LEN([DATE])-3,2)))
)

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

@Coglizer

Pude reproducir el error si mi columna DATE tiene un valor de 3 dígitos


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

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.