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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Removing variable amount of characters from front of cell

Hi all!

 

I'm working with badge numbers, and some of our badges start with either one letter, two letters, or none at all.

 

Joe ShmoZZ1234125
Derrick DieterZ23412344
Paul Piper124244444
Aaron Iron124321441
Bowlsey Bollsly564234123

 

Is there any way that I can create something that recognizes the first few characters as letters and, if there aren't none, to leave the cell alone?

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("JcwxC8JADIbhvxIyd0kudbd00ang1uOGIgEPoyfXivTf26bf8C4PfDHitSjcHq+CDY4jcRDiFlMTsdda8/0JfdZF686OQcR5mL4GQ/44EQvLPqfzVMsbLlsOCkwi5NSVn826QlfMZls3b09y/GJKfw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Badge = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Num Only", each Text.Select([Badge], {"0".."9"}))
in
    #"Added Custom"

Screenshot 2021-06-24 195845.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!

View solution in original post

4 REPLIES 4
negi007
Community Champion
Community Champion

@Anonymous you can create a column like below in your data

 

Column =
var chr_1 = MID('Table'[badge ],1,1)*1
var chr_2 = MID('Table'[badge ],2,1)*1
var chr_3 = MID('Table'[badge ],1,2)*1
var ctr = ISERROR(chr_1)+ISERROR(chr_2)

return
MID('Table'[badge ],1,ctr)
 
 
negi007_0-1624557604144.png

 




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



Proud to be a Super User!


Follow me on linkedin

CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("JcwxC8JADIbhvxIyd0kudbd00ang1uOGIgEPoyfXivTf26bf8C4PfDHitSjcHq+CDY4jcRDiFlMTsdda8/0JfdZF686OQcR5mL4GQ/44EQvLPqfzVMsbLlsOCkwi5NSVn826QlfMZls3b09y/GJKfw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Badge = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Num Only", each Text.Select([Badge], {"0".."9"}))
in
    #"Added Custom"

Screenshot 2021-06-24 195845.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!

Anonymous
Not applicable

Thanks! Worked like a charm and I was able to link the id with another table in order to pull their names into a bigger dataset.

@Anonymous You can also try below way

 

Column =
var chr_1 = MID('Table'[badge ],1,1)*1
var chr_2 = MID('Table'[badge ],2,1)*1
var chr_3 = len('Table'[badge ])*1
var ctr = (ISERROR(chr_1)+ISERROR(chr_2))*1

return
//chr_3
//ctr

MID('Table'[badge ],ctr+1,chr_3-ctr)
 
negi007_0-1624592838099.png

 




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



Proud to be a Super User!


Follow me on linkedin

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors