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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors