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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Expression.Error: Cannot convert value #datetime to type text

Hello!

Could you please help me with this, I have many columns ( [Source.file], [time], [serie], [Altitude], etc). I just want copy the previous row altitude to the current row in a new column: [Altura0], based on the previous [time]  

I am getting this error : 

    Expression.Error: No se puede convertir el valor #datetime(2021, 2, 6, 22, 16, 9) al tipo Text.
    Detalles:
    Value=6/02/2021 22:16:09
    Type=[Type]

 

I don't know what to do 😭 I am new on M language. 

Please see the code in Bold (that's what i wrote).⬇️

 

Please!! and thank you! 

---------------------------

#"Rango de texto insertado" = Table.AddColumn(#"Tipo cambiado", "Rango de texto", each Text.Middle([Source.Name], 20, 6), type text),
#"Data Logger Source" = Table.RenameColumns(#"Rango de texto insertado",{{"Rango de texto", "Serie"}}),

#"Personalizada agregada" = Table.AddColumn(#"Data Logger Source", "Altura0", each let
#"serie actual" = [Serie],
#"tiempo actual" = [Time],
#"ciclo total serie" = Table.SelectRows(#"Data Logger Source", each [Serie] = #"serie actual"),
#"ciclo tiempo" = Table.SelectRows(#"ciclo total serie", each [Time] < #"tiempo actual"),
#"max time anterior" = if not Table.IsEmpty(#"ciclo tiempo") then List.Max(Table.Column(#"ciclo tiempo", [Time]), 0) else 0,
#"max time" = Text.From(#"max time anterior")
#"Altura anterior" = if #"max time"<> 0 then Table.Column(Table.SelectRows(#"ciclo tiempo", each Text.From([Time]) = #"max time"), [#"Altitude[m]"]) else 0
in
#"Altura anterior", type number)

 

 

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

I found some similar posts, please kindly refer to

[Expression.Error] We cannot convert the value #date(2017, 4, 3) to Type Text

Expression.Error: We cannot convert the value to type Text.

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Anonymous
Not applicable

It's not clear what your "in" statement ends up evaluating to, but that is not your question; it looks like in your "max time" statement, you change [Time] to type text, but then you have if #"max time" <> 0, where it should instead be:

if #"max time" <> "0"

The zero should be a text value for that statement.

 

--Nate

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.