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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
thomas_coltrain
Frequent Visitor

Text Replace help

Hey,

I need assistance in removing "years" from the data output in a column.  The data comes in labeled as..

1 Year

2 Year

3 Year etc,

I need it to just display a # like

1

2

3

4 and so on

I tried the text.replace and kept getting an error 

 

Text.Replace([# of Years], {"Year", ""})

Thanks,

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@thomas_coltrain 
Please use the following

1.png

Year Number = 
VAR String = Data[Year]
VAR NumberLength = SEARCH ( "Y", String, 1, 3 ) - 2
RETURN
    LEFT ( String, NumberLength )

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

@thomas_coltrain 
Please use the following

1.png

Year Number = 
VAR String = Data[Year]
VAR NumberLength = SEARCH ( "Y", String, 1, 3 ) - 2
RETURN
    LEFT ( String, NumberLength )

Fast service!! Thank you for the help!

tamerj1
Super User
Super User

@thomas_coltrain 
You are posting in dax forum but seems you are looking for power quer solution. However this can be solved in dax. Are you intersted in dax solution?

Opps!  Sure I don't mind if its in DAX

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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