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
smpa01
Super User
Super User

Microsoft.OleDb.Date value - Problemas con la fecha de tipo de columna con R

Hola Expertos,

Cada vez que tengo una columna de fecha en mi conjunto de datos en la que ejecuto un script de R, devuelve un valor extraño.

Por ejemplo, estas dos líneas

Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1NNI1MlXSUTI0MFCK1YEJGuoaGQAFjVAEgcgCKGgMEowFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Integer = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Integer", Int64.Type}})

Devuelve

Fecha Entero
12/25/2020 100
11/20/2020 200
10/18/2020 300

Si escribo otras dos líneas de R

#"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)x<-data.frame(dataset)",[dataset=#"Changed Type"]),
    #"""x""" = #"Run R script"{[Name="x"]}[Value]
in
    #"""x"""

se convierte en este

Fecha Entero
Microsoft.OleDb.Date 100
Microsoft.OleDb.Date 200
Microsoft.OleDb.Date 300

Todo el guión sigue

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1NNI1MlXSUTI0MFCK1YEJGuoaGQAFjVAEgcgCKGgMEowFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Integer = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Integer", Int64.Type}}),
    #"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)x<-data.frame(dataset)",[dataset=#"Changed Type"]),
    #"""x""" = #"Run R script"{[Name="x"]}[Value]
in
    #"""x"""

Más allá de la base R probé otras bibliotecas también y cada uno devuelve lo mismo.

Por ejemplo, con data.table

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1NNI1MlXSUTI0MFCK1YEJGuoaGQAFjVAEgcgCKGgMEowFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Integer = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Integer", Int64.Type}}),
    #"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)library(data.table)#(lf)x<-data.table(dataset)",[dataset=#"Changed Type"]),
    #"""x""" = #"Run R script"{[Name="x"]}[Value]
in
    #"""x"""

Me está haciendo difícil. ¿Alguien sabe cómo depurar esto por favor.

Gracias de antemano.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 REPLY 1
smpa01
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1NNI1MlXSUTI0MFCK1YEJGuoaGQAFjVAEgcgCKGgMEowFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Integer = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type text}, {"Integer", Int64.Type}}),
    #"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)library(data.table)#(lf)x<-data.table(dataset)",[dataset=#"Changed Type"]),
    #"""x""" = #"Run R script"{[Name="x"]}[Value],
    #"Changed Type1" = Table.TransformColumnTypes(#"""x""",{{"Date", type date}})
in
    #"Changed Type1"
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.