Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
101Mathew
Resolver II
Resolver II

Check if each row in a column contains A through Z

I all I've used Text.Remove([Pol Ref], {"0".."9"}), to quickly remove all numric values from a text string column with no problems.

 

I wanted to create a similar, type of custom column, this time to check if each row in a column contains A through to Z

 

So I create another custom column, with the following M code

 

if
  Text.Contains([Postcode], {"A".."Z"})
then "Keep"
 
else "Remove"

 

However the it returns Error on each row for my Postcode column, advising

 

"Expression.Error: We cannot convert a value of type List to type Text.
Details:
    Value=List
    Type=Type"

 

I'm rather new to programming, and new to programming in M.  Can anyone advise a solution for such a newbie?

2 ACCEPTED SOLUTIONS

@Zubair_Muhammad

 

Thank you,  we hit a error at the "then" section of the M coding

 

If seems like M does not allow to create conditional formula onto lists?!?

View solution in original post

@101Mathew

 

It works when I use some sample data

Take a look at attached Excel file's query editor

 

werewr.png

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

@101Mathew

 

Try this revision

 

=if
List.ContainsAny(Text.ToList([Column1]),{"a".."z"}&{"A".."Z"})
then
"Keep"
else
"Remove"

@Zubair_Muhammad

 

Thank you,  we hit a error at the "then" section of the M coding

 

If seems like M does not allow to create conditional formula onto lists?!?

@101Mathew

 

It works when I use some sample data

Take a look at attached Excel file's query editor

 

werewr.png

@Zubair_Muhammad

 

Thank you, and sorry

 

I made a mistake with the brackets, it's annoying that Power Query does not give better feedback on issues with my programming.

 

It now works very well.

 

Cheers

Mathew

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors