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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Andybr
Frequent Visitor

Search for a specific text pattern

Hi,

I'm wanting to search for a particular pattern in a column (3 digits then 4 digits seperated by a dash) and return true / false if there's a match 

 

for example:

123-4567 True

A23-4567 False

000-8900 True

 

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Andybr maybe try something like this, add a new column:

 

Both Numbers = 
VAR __left = IF ( IFERROR (  VALUE ( LEFT ( Match[Data], 3 ) ),  -1 ) = -1, FALSE(), TRUE() ) 
VAR __right = IF ( IFERROR  (  VALUE ( RIGHT ( Match[Data], 4 ) ), -1 ) = -1, FALSE(), TRUE() ) 
RETURN
IF ( __left && __right, TRUE(), FALSE() )

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@Andybr maybe try something like this, add a new column:

 

Both Numbers = 
VAR __left = IF ( IFERROR (  VALUE ( LEFT ( Match[Data], 3 ) ),  -1 ) = -1, FALSE(), TRUE() ) 
VAR __right = IF ( IFERROR  (  VALUE ( RIGHT ( Match[Data], 4 ) ), -1 ) = -1, FALSE(), TRUE() ) 
RETURN
IF ( __left && __right, TRUE(), FALSE() )

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

CNENFRNL
Community Champion
Community Champion

Intrinsically, DAX isn't designed for the purpose of pattern check,

Screenshot 2021-06-11 002135.png

M might do the trick, but fairly verbose,

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQy1jUxNTNXitWJVnJE5hgYGOhaWBoYgDmWlrpmQABm6wIljIFAKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Data = _t]),
    #"Added Custom" = Table.AddColumn(
        Source, 
        "Chk_PQ", 
        each 
        let
            l = Text.Split([Data], "-"),
            chk1 = List.Count(l) = 2,
            chk2 = (Text.Length(l{0}) = 3) and List.Accumulate(Text.ToList(l{0}), true, (s,c) => s and not (try Number.From(c))[HasError]),
            chk3 = Text.Length(l{1}) = 4 and List.Accumulate(Text.ToList(l{1}), true, (s,c) => s and not (try Number.From(c))[HasError])
        in
            chk1 and chk2 and chk3
    )
in
    #"Added Custom"

 

Screenshot 2021-06-11 002343.png

 

Of coz, nothing is match for Regular Expression in this regard,

RegEx CheckRegEx Check


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!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.