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
Akatsuki
Frequent Visitor

undefined

Hello Everyone ,

 

Am new to Power BI, can anyone please help ?? 

 

Requirement :- we want to trim the data 

Like :- (1 yr), (11 yr) , (yr) these data should

be removed from the Name column, like below image: -

 

Please Note :- sometimes middle name, can also be mentioned in the bracket at the last, like third row, but want to keep the full name

 

IMG_20230407_122226.jpg

5 REPLIES 5
tamerj1
Super User
Super User

Hi @Akatsuki 

Please try

 

Expected Name =
VAR String =
    SUBSTITUTE ( 'Table'[Name], " yr", "yr" )
VAR Items =
    SUBSTITUTE ( String, " ", "|" )
VAR Length =
    PATHLENGTH ( Items )
VAR T1 =
    GENERATESERIES ( 1, Length, 1 )
VAR T2 =
    ADDCOLUMNS ( T1, "@Item", [Value] )
VAR T3 =
    FILTER ( T2, NOT CONTAINSSTRING ( [@Item], "yr" ) )
RETURN
    CONCATENATEX ( T3, [@Items], " ", [Value], ASC )

 

Thank you sir, will try it and let you know

@Akatsuki 
Yes but there is still a small problem. I will update the code in my original reply.

FreemanZ
Super User
Super User

hi @Akatsuki 

 

In Power Query Editor, try to split the name column with the right most (

 

check more here:

https://learn.microsoft.com/en-us/power-query/split-columns-delimiter

Thank you for replying Sir, But  I want a calculated column using dax function. 

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.