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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! 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
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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