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.
Hola
Tengo en mi archivo un colomn con TimeStamps como este.
como usted ve la fecha es una mezcla de 8 dígitos, 9 dígitos o 10 dígitos.
Quiero tratar de hacer Colomn's Date & Time Colomnn
¿Cómo puedo hacer coloms separados con fecha y hora de esto?
Solved! Go to Solution.
@Frixel Pruebe lo siguiente:
Date Column =
VAR __Date = SUBSTITUTE(LEFT([Column1],SEARCH(" ",[Column1],,0)),"(","")
VAR __FirstHyphen = SEARCH("-",__Date,,0)
VAR __SecondHyphen = SEARCH("-",__Date,__FirstHyphen+1,0)
VAR __Day = LEFT(__Date,SEARCH("-",__Date,,0)-1)
VAR __Month = MID([Column1],__FirstHyphen+2,__SecondHyphen - __FirstHyphen - 1)
VAR __Year = RIGHT(__Date,LEN(__Date) - __SecondHyphen)
VAR __NewDate = __Month & "-" & __Day & "-" & __Year
RETURN
__NewDate
PBIX se adjunta debajo de sig. Tabla (17a)
@Frixel IMHO, es un peso ligero para hacer frente a Power Query, ya que hay un tipo de fecha específico llamado datetime para contener estos datos. Pls probar el código M a continuación,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W0jDTNbLUNTIwMlAwsLAyMLIyMdFUitUBShjqmkPFza2MgVKWQPFYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
Trans = Table.TransformColumns(Source, {{"Column1", each Text.Remove(_, {"(", ")"})}}),
#"Changed Type" = Table.TransformColumnTypes(Trans,{{"Column1", type datetime}}),
Split = Table.TransformColumns(#"Changed Type", {"Column1", each [Date = DateTime.Date(_), Time = DateTime.Time(_)]}),
#"Expanded Column1" = Table.ExpandRecordColumn(Split, "Column1", {"Date", "Time"}, {"Date", "Time"})
in
#"Expanded Column1"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@Frixel , ¿tiene toda la fecha y hora en formato dd-MM .becasue en ese caso sólo necesita eliminar ( y ) y se puede obtener la fecha con esta configuración
@Frixel ¿Reemplazar el ( ) con blanco (nada) y luego dividir en el espacio?
@Frixel En Power Query, haga lo siguiente:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W0jDTNbLUNTIwMlAwsLAyMLIyMdFUitUBShjqmkPFza2MgVKWQPFYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","(","",Replacer.ReplaceText,{"Column1"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",")","",Replacer.ReplaceText,{"Column1"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value1", "Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type date}, {"Column1.2", type time}})
in
#"Changed Type1"
@Frixel No, eso es Power Query.
@Frixel OK, si lo estás haciendo a través de DAX, entonces sería:
Date Column =
SUBSTITUTE(LEFT([Timestamp],SEARCH(" ",[Timestamp],,0)),"(","")
Time Column =
SUBSTITUTE(RIGHT([Timestamp],LEN([Timestamp]) - SEARCH(" ",[Timestamp],,0)),")","")
Genial, ahora confiere la hora y la fecha.
Pero...
El problema es que la fecha se invierte, si sabes a lo que me refiero.
1a fila 1a colomn 1 de julio de 2020, etc.
@Frixel Pruebe lo siguiente:
Date Column =
VAR __Date = SUBSTITUTE(LEFT([Column1],SEARCH(" ",[Column1],,0)),"(","")
VAR __FirstHyphen = SEARCH("-",__Date,,0)
VAR __SecondHyphen = SEARCH("-",__Date,__FirstHyphen+1,0)
VAR __Day = LEFT(__Date,SEARCH("-",__Date,,0)-1)
VAR __Month = MID([Column1],__FirstHyphen+2,__SecondHyphen - __FirstHyphen - 1)
VAR __Year = RIGHT(__Date,LEN(__Date) - __SecondHyphen)
VAR __NewDate = __Month & "-" & __Day & "-" & __Year
RETURN
__NewDate
PBIX se adjunta debajo de sig. Tabla (17a)
@Greg_Deckler Gracias
Parece que ahora tengo el formato date correcto.
¿Puedo ahora también mover la fecha y hora de Colomns en otro lugar?
No puedo encontrar una opción para mover colomns a otro lugar
@Frixel No estoy seguro de lo que quieres decir con eso. Las columnas calculadas DAX siempre se colocan al final de una tabla.
@Frixel Tratar:
Date Column =
VAR __Date = SUBSTITUTE(LEFT([Column1],SEARCH(" ",[Column1],,0)),"(","")
VAR __FirstHyphen = SEARCH("-",__Date,,0)
VAR __SecondHyphen = SEARCH("-",__Date,__FirstHyphen+1,0)
VAR __Day = LEFT(__Date,SEARCH("-",__Date,,0)-1)
VAR __Month = MID([Column1],__FirstHyphen+2,__SecondHyphen - __FirstHyphen - 1)
VAR __Year = RIGHT(__Date,LEN(__Date) - __SecondHyphen)
VAR __NewDate = __Month & "-" & __Day & "-" & __Year
RETURN
__NewDate
PBIX se adjunta debajo de sig. Tabla (17a)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |