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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
jamuka
Helper IV
Helper IV

Split a Column Dynamically based on another columns length

Hello all,

 

Our product names should start with Brand Names then product details. Our system allows 30 characters for product name.

Therefore sometimes we have to tweak names.

I'd like to check names whether they include Brand Names or not.

I want to split names into two columns based on brand lengths, so I can check whether products have correct brand names or not.

I tried to use solution in another topic but couldn't update formula for my need.

 

Solved: Split a column by positions in another column - Microsoft Fabric Community

 

kind regards

 

BrandLengthNameName.1Name.2Check (Brand with Name.1
XYZ4XYZ SUNGLASSES PR45630XYZSUNGLASSES PR45630TRUE
ABC TOYS9ABCTOYS ORGANIC WOOD BLOCK 400ABCTOYS ORGANIC WOOD BLOCK 400FALSE
ABC TOYS9ABC TOYS WOOD BLOCKS 50 PIECESABC TOYSWOOD BLOCKS 50 PIECESTRUE
1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dYs7CoAwEAWv8tjaImAULGMMEhRXXMVPyP2v4WplYzHwBualRMd5UUFW0QXZpn50IkEwL7aqS0O5SORaj5VP0apRVB8DL72bosfO3KEd2Q+w5u/x6icVVAZzDD4I5XwD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Brand = _t, Lenght = _t, Name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Brand", type text}, {"Lenght", Int64.Type}, {"Name", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Name.1", each [ 
   t =  if 
Text.Range([Name], [Lenght]-1, 1)=" " then Splitter.SplitTextByLengths({[Lenght], 1000})([Name]) {0} else Splitter.SplitTextByLengths({[Lenght]-1, 1000})([Name]) {0},
to = Text.Trim(t)][to]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Name.2", each [
    t = 
if 
Text.Range([Name], [Lenght]-1, 1)=" " then Text.Range([Name], [Lenght])  else Text.Range([Name], [Lenght]-1),
to = Text.Trim(t)][to]),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Check (Brand with Name.1", each [Brand] =[Name.1])
in
    #"Added Custom2"

View solution in original post

2 REPLIES 2
Ahmedx
Super User
Super User

pls try this

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dYs7CoAwEAWv8tjaImAULGMMEhRXXMVPyP2v4WplYzHwBualRMd5UUFW0QXZpn50IkEwL7aqS0O5SORaj5VP0apRVB8DL72bosfO3KEd2Q+w5u/x6icVVAZzDD4I5XwD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Brand = _t, Lenght = _t, Name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Brand", type text}, {"Lenght", Int64.Type}, {"Name", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Name.1", each [ 
   t =  if 
Text.Range([Name], [Lenght]-1, 1)=" " then Splitter.SplitTextByLengths({[Lenght], 1000})([Name]) {0} else Splitter.SplitTextByLengths({[Lenght]-1, 1000})([Name]) {0},
to = Text.Trim(t)][to]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Name.2", each [
    t = 
if 
Text.Range([Name], [Lenght]-1, 1)=" " then Text.Range([Name], [Lenght])  else Text.Range([Name], [Lenght]-1),
to = Text.Trim(t)][to]),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Check (Brand with Name.1", each [Brand] =[Name.1])
in
    #"Added Custom2"

thank you very much for your help @Ahmedx 

 

have a nice day

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

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.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.