Forum Discussion
Expression.Error: We cannot convert the value #date(2023, 1, 2) to type Text
- 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.
In one of the steps in the query I had a function causing that issue when in the column where Power Query expected to find text, for example, C or A, it was finding a date. The solution was to fix the source file (Excel) removing dates from the column where should be text or put Text.From() around the column name within Text.Contains() function. A piece of code causing the issue in my case:
each Text.Contains([#"Bank Details (C/A/O)"], "C") or ....