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
UsePowerBI
Post Prodigy
Post Prodigy

Expression.Error: We cannot convert a value of type Function to type Number.

Hello

 

Any idea why the below results in error?

 

= Table.RemoveRows(#"Changed Type", each not Text.Contains([A], "some1") and [B]<0)

 

Expression.Error: We cannot convert a value of type Function to type Number.
Details:
Value=[Function]
Type=[Type]

 

I do have specified in a previous step [A] to be text and [B] to be integer.

 

Thanks!

1 ACCEPTED SOLUTION

Hi  @UsePowerBI , 

 

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: 

RicoZhou_1-1650012856279.png

Result is as below.

RicoZhou_0-1650012850121.png

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.

 

 

View solution in original post

3 REPLIES 3
UsePowerBI
Post Prodigy
Post Prodigy

@HotChilli  but the same applies to Table.SelectRows ?

Hi  @UsePowerBI , 

 

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: 

RicoZhou_1-1650012856279.png

Result is as below.

RicoZhou_0-1650012850121.png

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.

 

 

HotChilli
Super User
Super User

Table.RemoveRows   takes a table and a number as parameters.  The code here passes a function as the 2nd parameter.

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.