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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
NewinPBi
Frequent Visitor

valid letters or numbers

Hi,

I am validating a field, this field should only composed of letters(any and/or numbers, no any other character like -,_@,$%^& etc.

Valid letters/numbers:  ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789’ 

Help appreciated and thanks in advance.

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @NewinPBi 

 

Based your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

Table:

h1.png

 

Valid:

h2.png

 

You may create a calculated column or a measure as below.

Calculated colummn:
IsValid Column = 
var _letter = 'Table'[Validation]
var tab = 
ADDCOLUMNS(
    GENERATESERIES(1,LEN(_letter),1),
    "letter",
    RIGHT(LEFT(_letter,[Value]),1)
)

return
    IF(
        LEN(_letter)=
        COUNTROWS(
            FILTER(
                tab,
                [letter] in DISTINCT(Valid[Valid letter])
            )
        ),
        1,0
    )

Measure:
IsValid Measure = 
var _letter = MIN('Table'[Validation])
var tab = 
ADDCOLUMNS(
    GENERATESERIES(1,LEN(_letter),1),
    "letter",
    RIGHT(LEFT(_letter,[Value]),1)
)

return
IF(
    HASONEVALUE('Table'[Validation]),
    IF(
        LEN(_letter)=
        COUNTROWS(
            FILTER(
                tab,
                [letter] in DISTINCT(Valid[Valid letter])
            )
        ),
        1,0
    )
)

 

Result:

h3.png

 

Best Regards

Allan

 

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

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @NewinPBi 

 

If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

 

Best Regards

Allan

v-alq-msft
Community Support
Community Support

Hi, @NewinPBi 

 

Based your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

Table:

h1.png

 

Valid:

h2.png

 

You may create a calculated column or a measure as below.

Calculated colummn:
IsValid Column = 
var _letter = 'Table'[Validation]
var tab = 
ADDCOLUMNS(
    GENERATESERIES(1,LEN(_letter),1),
    "letter",
    RIGHT(LEFT(_letter,[Value]),1)
)

return
    IF(
        LEN(_letter)=
        COUNTROWS(
            FILTER(
                tab,
                [letter] in DISTINCT(Valid[Valid letter])
            )
        ),
        1,0
    )

Measure:
IsValid Measure = 
var _letter = MIN('Table'[Validation])
var tab = 
ADDCOLUMNS(
    GENERATESERIES(1,LEN(_letter),1),
    "letter",
    RIGHT(LEFT(_letter,[Value]),1)
)

return
IF(
    HASONEVALUE('Table'[Validation]),
    IF(
        LEN(_letter)=
        COUNTROWS(
            FILTER(
                tab,
                [letter] in DISTINCT(Valid[Valid letter])
            )
        ),
        1,0
    )
)

 

Result:

h3.png

 

Best Regards

Allan

 

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

camargos88
Community Champion
Community Champion

Hi @NewinPBi ,

 

You can try this custom column:

let _validItems = {"0".."9"} & {"A".."Z"} in
if Text.Length(Text.Remove(Text.Upper([Text]), _validItems)) > 0 then 0 else 1

 

Capture.PNG 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



This works as a custom column, but  I am trying to achieve this using an existing column name VALIDATION, I have other  IF conditions too on other fields

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.