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
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
v-stephen-msft
Community Support
Community Support

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.

 

 

watkinnc
Super User
Super User

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


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

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.

Top Solution Authors