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! Learn more

Reply
ritanoori
Resolver I
Resolver I

Custom column - if first 9 characters column is alphanumeric or numeric

Hello Everyone

I'm trying to create a custom column in power querey where if the first 9 characters of [description] is alphanumeric then "Y" else  if the first 9 characters of [description] is numeric then "X" else "N/A"

 

can you please help. Thanks. 

1 ACCEPTED SOLUTION

@ritanoori , Try something like

if Value.Is(Text.Start([description],9) Int64.Type) then "Y" else if Value.Is(Text.Start([description],9) Text) then "X" else "N/A"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @ritanoori ,

You can create this custom column in power query:

    Table.AddColumn(
        #"Changed Type", 
        "Custom", 
        each if 
            Value.Is(
                 Value.FromText(Text.Start([description],9)),Int64.Type
            ) 
        then "X"
        else if 
        Text.Length(
            Text.Remove(
                Text.Start([description],9),
                {"a".."z","A".."Z"})
            ) = 0
        then "Y"
        else "N/A"
    )

re.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@ritanoori , Try a new column like

 

new column =
var _chk = left([description],9)
return
Switch(True(),
ISNUMBER(_chk), "Y"
ISTEXT(_chk) ,"X"
,"N/A")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks. But I need this in power querey. 

@ritanoori , Try something like

if Value.Is(Text.Start([description],9) Int64.Type) then "Y" else if Value.Is(Text.Start([description],9) Text) then "X" else "N/A"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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