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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Replace first value on department

Hi,

 

I want to change de fist number on al department that start with a 7 to 4. How do i do this easy?

 

Dept
4732
7756
64000
7550

 

Thanks for help

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Do you mean to replace the first 7 to 4? You can add a custom column or Transform the original column, and if your column is not Text, you can also wrap Text.From, paste it in Advanced Editor, it is a way in M

Vera_33_0-1617758929867.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjE3NlKK1YlWMjc3NQMzzEwMDAwgQqamQEYsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Dept = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dept", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.At( [Dept],0)="7" then "4"&Text.End([Dept],Text.Length([Dept])-1) else [Dept])
in
    #"Added Custom"

 

View solution in original post

1 REPLY 1
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Do you mean to replace the first 7 to 4? You can add a custom column or Transform the original column, and if your column is not Text, you can also wrap Text.From, paste it in Advanced Editor, it is a way in M

Vera_33_0-1617758929867.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjE3NlKK1YlWMjc3NQMzzEwMDAwgQqamQEYsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Dept = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dept", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.At( [Dept],0)="7" then "4"&Text.End([Dept],Text.Length([Dept])-1) else [Dept])
in
    #"Added Custom"

 

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