Forum Discussion

beatrizalbuqu's avatar
beatrizalbuqu
Frequent Visitor
3 years ago
Solved

Expression.Error: We cannot convert the value #date(2023, 1, 2) to type Text

Hello! I've been trying to fix the error below but I can't figure why is this function is trying to convert a date to a text. Expression.Error: We cannot convert the value #date(2023, 1, 2) to ...
  • m_dekorte's avatar
    m_dekorte
    3 years ago

    Looking again there appears to be an additional issue
    is this [#"UK Holidays.Date"] meant to refer to itemss in this list: Table.ToList(#"UK Holidays") ?

     

    If so try this instead:
    List.Count( List.Select( Table.ToList(#"UK Holidays"), (x)=> x >= inicial and x <= final ))

     

    if you're still getting a type conversion error, break your formula down and return each component to validate that it is returning the correct value and type you require. I find that nesting a record is a convenient way to do just that, that will look something like this.

     

    Table.AddColumn( #"November days", "November holidays", each
        [
            h = Table.ToList(#"UK Holidays"),
            i = inicial,
            f = final,
            a = List.Select( h, (x)=> x >= i and x <= f ),
            b = List.Count( a )
        ]
    )

     

    When the record is returned, click off to the side in the whitespace to see its content, in an additional preview window below the main one.

    I hope this helps you to resolve it.