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
InsightSeeker
Helper III
Helper III

Validation of Alphanumeric Values Using DAX in Power BI

Hello,

 

I need help with validating values using DAX to determine if they contain only alphanumeric values.

 

If the value contains only alphanumeric values, it should return TRUE; otherwise, it should return FALSE.

 

Value
gtest@gmail.com
16546854
464213
1641654
564646
646464
546498
46464
64646464
646486
64646546
ASW4646464
AW54646
AQ464654
AD446464
AS4646DD
ASDSWSD
KLHH
OJOJ
POJPOJP
3 REPLIES 3
marcelsmaglhaes
Super User
Super User

@InsightSeeker 

You can create a calculated column in your table as shown below. Feel free to adjust the formula or ask further questions!

AlphanumericCheck =
VAR CurrentValue = 'YourTable'[YourColumn]
VAR Length = LEN(CurrentValue)
VAR CheckChar =
    SUMX(
        GENERATESERIES(1, Length),
        VAR CurrentChar = MID(CurrentValue, [Value], 1)
        RETURN
            IF(
                NOT (
                    (UNICODE(CurrentChar) >= UNICODE("A") && UNICODE(CurrentChar) <= UNICODE("Z")) ||
                    (UNICODE(CurrentChar) >= UNICODE("a") && UNICODE(CurrentChar) <= UNICODE("z")) ||
                    (UNICODE(CurrentChar) >= UNICODE("0") && UNICODE(CurrentChar) <= UNICODE("9"))
                ),
                1,
                0
            )
    )
RETURN
    IF(CheckChar > 0, FALSE, TRUE)

Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



Hi @marcelsmaglhaes 

 

I am getting below error when i use the above DAX suggestion.

 

In some of my cells i dont have any value which might be affecting the result.

 

InsightSeeker_0-1722612591304.png

 

Regards

Gaurav

 

To handle blank values in your column and prevent GENERATESERIES from crashing, you can add a check for blank values in the VAR Length declaration and handle those cases appropriately

AlphanumericCheck =
VAR CurrentValue = 'YourTable'[YourColumn]
VAR Length = LEN(CurrentValue)
VAR CheckChar =
IF(
ISBLANK(CurrentValue),
0, // No characters to check, so treat as alphanumeric
SUMX(
GENERATESERIES(1, Length),
VAR CurrentChar = MID(CurrentValue, [Value], 1)
RETURN
IF(
NOT (
(UNICODE(CurrentChar) >= UNICODE("A") && UNICODE(CurrentChar) <= UNICODE("Z")) ||
(UNICODE(CurrentChar) >= UNICODE("a") && UNICODE(CurrentChar) <= UNICODE("z")) ||
(UNICODE(CurrentChar) >= UNICODE("0") && UNICODE(CurrentChar) <= UNICODE("9"))
),
1,
0
)
)
)
RETURN
IF(CheckChar > 0, FALSE, TRUE)


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



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.