Forum Discussion
Expression.Error: We cannot convert a value of type Function to type Number.
- Anonymous4 years ago
Hi Anonymous ,
As far as I know "each not Text.Contains([A], "some1") and [B]<0" part works as a function.
As HotChilli mentioned Table.RemoveRows will use number in second part.
Table.RemoveRows(table as table, offset as number, optional count as nullable number) as table
Table.SelectRows will use function in second part. So I suggest you to use Table.SelectRows in your code, it will work.
Table.SelectRows(table as table, condition as function) as tableMy Sample:
Result is as below.
M Code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs7PTTVU0lEyVIrVgfCMgDxdCNcRJqtrDJc2BnKBvFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"B", Int64.Type}}), #"Remove rows" = Table.SelectRows(#"Changed Type", each not Text.Contains([A], "some1") and [B]<0) in #"Remove rows"Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HotChilli but the same applies to Table.SelectRows ?
Hi Anonymous ,
As far as I know "each not Text.Contains([A], "some1") and [B]<0" part works as a function.
As HotChilli mentioned Table.RemoveRows will use number in second part.
Table.RemoveRows(table as table, offset as number, optional count as nullable number) as table
Table.SelectRows will use function in second part. So I suggest you to use Table.SelectRows in your code, it will work.
Table.SelectRows(table as table, condition as function) as table
My Sample:
Result is as below.
M Code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs7PTTVU0lEyVIrVgfCMgDxdCNcRJqtrDJc2BnKBvFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"B", Int64.Type}}),
#"Remove rows" = Table.SelectRows(#"Changed Type", each not Text.Contains([A], "some1") and [B]<0)
in
#"Remove rows"
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.