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
RahulPBI
Helper I
Helper I

Split or Trim Rows Based on Certain Criteria

Hi Experts

I have a few thousand rows of data in one column and now have a need to this data into seperate columns

Tried to split columns and even tried Format without much luck

 

Does anyone have a suggestion on how can i split my column based on certain criteria?

Format of coulmn example

 

LP53 C60.B 4W 70A 3K

SP53 R65.B 36L 24W 70A 4K

FT54 R.B 24L 48W/35A 3K

OC20 ABC.B 12 L 18W/70A 5K

 

Result I would like power query to split the above emaple and show in as below

 

Column 1Column2Column3Column4Column5Column6
LP53C60.B 4W70A3k
SP53R65.B36L24W70A4K
FT54R.B12L48W35A3K
OC20ABC.B12 L18W70A5K

 

My problem is there are diffrent many instances and some could have some data not there, like row one

How do I get the rows broken up and the about columns and if the criteria is n

 

 

6 REPLIES 6
Mariusz
Community Champion
Community Champion

Hi @RahulPBI 

 

Try this,

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("PctNCoAgEAbQq3y4jvJnxtqm0CahsMCFeP9rNFK0frxaVTrZIXo9BlDBrFe4XbWhqqtD9izgfIL9lF7dbiZkMUsJtJTJ8T+PaDXWEEWNRYIR7pWF2wM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Text = _t]),
    #"Added Custom" = Table.AddColumn( Source, "Custom", each 
        let 
            split = Text.SplitAny( [Text], " /"  ),
            xxx = [
                column1 = 
                    List.Select( 
                        split, 
                        (i) =>     
                            List.Contains( { "A".."Z" }, Text.Start( i, 1 ) ) 
                            and List.Contains( { "0".."9" }, Text.End( i, 1 ) ) 
                    ){0},
                column2 =
                    List.Select( 
                        split, 
                        (i) => Text.EndsWith( i, ".B" ) 
                    ){0},
                column3 =
                    try List.Select( 
                        split, 
                        (i) => Text.EndsWith( i, "L" ) 
                    ){0} otherwise null,
                column4 =
                    List.Select( 
                        split, 
                        (i) => Text.EndsWith( i, "W" ) 
                    ){0},
                column5 =
                    List.Select( 
                        split, 
                        (i) => Text.EndsWith( i, "A" ) 
                    ){0},
                column6 =
                    List.Select( 
                        split, 
                        (i) => Text.EndsWith( Text.Upper( i ), "K" ) 
                    ){0}
            ] 
            
        in xxx

      
    ),
    #"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"column1", "column2", "column3", "column4", "column5", "column6"}, {"column1", "column2", "column3", "column4", "column5", "column6"})
in
    #"Expanded Custom"

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Hi Mariusz

Works very well and managed to incorporate it into my live pbix

It done the splits how I had wanted, but I didn't realise and take into account some other kind of splits

I have some variations and is it possible to split the below data? I have attached a test pbix file, hopefully that helps

 

 Capture1.JPG

 

Should be split like below

Column1Column2Column3Column4Column5Column6Column7
FT54G50.BEAM36 LED36W350mA3KD
FT54R.BEAM36 LED72W700mA4KMOTION
FT53G50.BEAM24 LED24W350mA3K7P EM [DI/SC]
MT32DY B65/6F+B65/6R12 LED12W350mA3KMOTION D M
MT32ZG70.BEAM2X6 LED36W700mA3000K2C DAL
RT32A60 BEAM24 LED72W700/1400mARGB/3000KDM
FL54G70.BEAM24 LED48W700mA4KADV
VL50G60.BEAM12 LED24W700mA4KNE 7D [DA/PE]
VL50G70.BEAM12 LED24W700mA4KNM 7G [DL/PE] I.S
FL50-S DYG65/18F+Z70/6F24 LED24W350mA4KNA 7D [DL/PE] I.S
RS30Z6012 LED24W700mARGBW 3KDA
TY15-AP  17W500mA3KGRND DA
LS410E./M.BEAM2x 3 LED12W700mA3000KREMOTE
OC220B.BEAMDRKLIGHT LED24W700mA3000KDALI
AS220B.BEAM12 LED36W1050mA3000KCATRY DA SPAL Mk4
AS220B.BEAM12 LED24W700mA3000KCATRY DM Mk3/4
OR120B.BEAM6 LED12W700mA3000KREMOTE
LC230M.BEAM12 LED12W350mA3000KFOOD 48V
L230 [FP] FRM  52W1400mA4000KDALI
FC26-CCM.BEAM36 LED144W350mARGBWDMX
LC23-CC [ZP] ZOM SPT 12 LED48W300mARGBWDMX
LC23-TX [FP] FRM 12 LED44W1300mA2700-6000KDALI

 

Its a very messy data, but working on fixing the new extries

 

Is it possible to acheive? Hopefully it is

 

Regards

 

Mariusz
Community Champion
Community Champion

Hi @RahulPBI 

 

What is the logic or rule for columns 1,2 and 7?

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

@Mariusz 

  1. The Column 1logic = All characters that come before G*.BEAM or R.BEAM or DY or A*.BEAM or Z*.BEAM and ** LED
  2. The Column 2 logic = All characters between the first column and *** LED
  3. The Column 7 logic = All characters after LEC with the exception the sign DIA or mA or mm

its a bit complicated, most of the Column 7 logic is after LEC, the other criteria is only to cater for old data, all new data will have the correct naming system

 

Regard

@Mariusz 

I realised that splitting the columns the way I needed was too hard as there were too many criterias, so I spent some time and manually fixed all the data so they are standardized

Could you please help me added just one criteria to the one that you provided before?

 

let
split = Text.SplitAny( [Product Description], " /""." ),
xxx = [
Column 1 =
List.Select(
split,
(i) =>
List.Contains( { "A".."Z" }, Text.Start( i, 1 ) )
and List.Contains( { "0".."9" }, Text.End( i, 1 ) )
){0},
Column 2 =
try List.Select(
split,
(i) => Text.EndsWith( i, ".BEAM" )
){0} otherwise "",
Column 3 =
try List.Select(
split,
(i) => Text.EndsWith( i, "LED") 
){0} otherwise "",
Column 4 =
try List.Select(
split,
(i) => Text.EndsWith( i, "W" )
){0} otherwise "",
Column 5 =
try List.Select(
split,
(i) => Text.EndsWith( i, "mA" )
){0} otherwise "",
Column 6 =
List.Select(
split,
(i) => Text.EndsWith( Text.Upper( i ), "K" )
){0}
]

in xxx

 

 

Column 3 is the only one that isn't working because there is a space before the word LED, if i add a space before the word it still doesnt work. How do I make it work? The data is always 2 or 3 numbers followed by space and then the word LED eg: 24 LED or 48 LED

 

Could you please help me add one more column? Criteria is show any text or numbers after the word LEC

 

Thanks 

 

Sorry below is the link for the pbix file

 

https://1drv.ms/u/s!ApULo7UfaUptgS9f8Kn4Nqfp0EH7?e=6ety9O

 

Regards

 

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.

Top Solution Authors