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
kassymov_su
Frequent Visitor

Filter if contains

Hi All,

 

While filtering having some issues. 

   M:

      = Table.SelectRows(#"Renamed Columns1", each ([Progress] <> 1 and Text.Contains([ID],"A")))

   Error:

       Expression.Error: We cannot convert the value 1 to type Text.
       Details:
       Value=1
       Type=[Type]

 

Error because column [ID] contains not only text but also numbers

Снимок123.PNG

 

1 ACCEPTED SOLUTION
Anand24
Super User
Super User

Hi @kassymov_su ,

Since columns Progress and ID are of different datatype and you have used in the same M query code line, you are receiving that error.

Bifurcating it into 2 different steps should resolve this:

    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Progress] <> 1)),//For Progress NOT EQUALS 1
    #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each not Text.Contains([ID], "A")) // FOR ID NOT CONTAINS "A"

 PFA .pbix with solution. You can go to advanced editor and check.

PBI_SuperUser_Rank@1x.png  

Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

Proud To Be a Super User !!!
LinkedIn

View solution in original post

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @kassymov_su ,


Could you tell me if your problem has been solved?
If it is, kindly Accept it as the solution. More people will benefit from it.
Or you are still confused about it, please provide me with more details about your problem.


Best Regards,
Stephen Tao

Anand24
Super User
Super User

Hi @kassymov_su ,

Since columns Progress and ID are of different datatype and you have used in the same M query code line, you are receiving that error.

Bifurcating it into 2 different steps should resolve this:

    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Progress] <> 1)),//For Progress NOT EQUALS 1
    #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each not Text.Contains([ID], "A")) // FOR ID NOT CONTAINS "A"

 PFA .pbix with solution. You can go to advanced editor and check.

PBI_SuperUser_Rank@1x.png  

Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

Proud To Be a Super User !!!
LinkedIn

kassymov_su
Frequent Visitor

Also can somebody tell me if I can filter the same but not contain "A"

 

= Table.SelectRows(#"Renamed Columns1", each ([Progress] <> 1 and Text.Not.Contains([ID],"A")))

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