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

View all the Fabric Data Days sessions on demand. View schedule

Reply
gauravnarchal
Post Prodigy
Post Prodigy

Validate numeric values and 8 digits length

Hello - I need help to create a measure to check if the values in the below table are all numeric and 8 digits then return ok else error. 

 

Table 1

 

Serial No
00809898
00810098
00810298
00810498
00810698
00810898
'00811098
00811298
CGH889
BGD
ISR
"909K
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @gauravnarchal ,

If you want to use meausre, please refer to what @mahoneypat  said and rewrite the formula to look like this:

 

Measure = 
IF(
    LEN(MAX('Table1'[Serial No])) = 8 
    &&  
    IFERROR(VALUE(MAX('Table1'[Serial No])), 0)>0,"Valid", "Error")

 


You can also use the m language of Power Query

Here are the steps you can follow:

1. Enter the Power query through Transform data and select Add Column – Custom Column

vyangliumsft_0-1628559774163.png

2. Enter the code

vyangliumsft_1-1628559774193.png

 

if
List.AllTrue({Text.Length([Serial No]) = 8 ,Value.Is(Value.FromText([Serial No]), type number)})
then
"corrert"
else
"error"

 

3. Result:

vyangliumsft_2-1628559774196.png

 

Best Regards,

Liu Yang

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

3 REPLIES 3
Anonymous
Not applicable

Hi  @gauravnarchal ,

If you want to use meausre, please refer to what @mahoneypat  said and rewrite the formula to look like this:

 

Measure = 
IF(
    LEN(MAX('Table1'[Serial No])) = 8 
    &&  
    IFERROR(VALUE(MAX('Table1'[Serial No])), 0)>0,"Valid", "Error")

 


You can also use the m language of Power Query

Here are the steps you can follow:

1. Enter the Power query through Transform data and select Add Column – Custom Column

vyangliumsft_0-1628559774163.png

2. Enter the code

vyangliumsft_1-1628559774193.png

 

if
List.AllTrue({Text.Length([Serial No]) = 8 ,Value.Is(Value.FromText([Serial No]), type number)})
then
"corrert"
else
"error"

 

3. Result:

vyangliumsft_2-1628559774196.png

 

Best Regards,

Liu Yang

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

 

CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjCwMLC0sLRQitUBcwwNDJA5RsgcE2SOGTIHZkBMqYGBkTlIyBDZGEOYMc7uHhYWlmCmk7sLmPYMDgLTlgaW3kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Serial No" = _t]),
    Flag = Table.AddColumn(Source, "8 digits", each Text.Length([Serial No])=8 and not (try Number.From([Serial No]))[HasError])
in
    Flag

Screenshot 2021-08-08 171732.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

mahoneypat
Microsoft Employee
Microsoft Employee

You can use a DAX column expression like this.  Replace Data with your actual table name.

 

IsValid = IF(LEN(Data[Serial No]) = 8 && IFERROR(VALUE(Data[Serial No]), 0)>0, "Valid", "Error")
 
mahoneypat_0-1628425378475.png

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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
Top Kudoed Authors