Split Alphabet only from Left Just before Numbers only in Power query

srehman

Board Regular
Joined
Jan 4, 2020
Messages
210
Office Version
  1. 2016
Platform
  1. Windows
Hi Team,

I have used following approach but not working

Text.Select([Rawdata],{"A".."Z"}) Data(AD1022010A) Result(ADA) wrong I need (AD)
Text.Select([Rawdata],{"0".."9"})





Split text & number power query.xlsx
DE
1Required Result
2RawdataStarting Alphabet from left before numbers
3AD102201AAD
4AIRLAIRL
5AP0332010BAP
6ARILS78ARILS
Sheet1
 

Attachments

  • text split from left.PNG
    text split from left.PNG
    4.6 KB · Views: 6

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi Sandy / Rich ( Individually on separate sheet i am success full to run below (RICH) steps, while i have to add in my current sheet.

I tried many errors.

Any thoughts


Below (RICH) steps I have to add in my current code.
==================================================================================
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Number = Table.AddColumn(Source, "Number", each Text.Select([Rawdata],{"0".."9"})),
LenRaw = Table.AddColumn(Number, "Length", each Text.Length([Rawdata]), Int64.Type),
LenNum = Table.AddColumn(LenRaw, "Length.1", each Text.Length([Number]), Int64.Type),
Subtract = Table.AddColumn(LenNum, "Subtraction", each [Length] - [Length.1], type number),
IF = Table.AddColumn(Subtract, "IF", each if [Length.1] = 0 then [Length] else [Subtraction]-1),
Range = Table.AddColumn(IF, "Text Range", each Text.Middle([Rawdata], 0, [IF]), type text),
TSC = Table.SelectColumns(Range,{"Rawdata", "Text Range"})
in
TSC
========================================================================================
I have to add Rich steps as last from last steps from my current code
Current Sheet Code

let
Source = Folder.Files("C:\Users\Rehmans\Desktop\Karcher Slotting\SOH"),
#"Removed Other Columns" = Table.SelectColumns(Source,{"Content", "Name"}),
#"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Custom", each Csv.Document([Content])),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Table.PromoteHeaders([Custom])),
#"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom1", "Custom.1", {"Tag ID", "SKU", "SKU Description", "Location", "Location Zone", "Sub Zone", "Qty On Hand", "Move Date", "Condition Code"}, {"Tag ID", "SKU", "SKU Description", "Location", "Location Zone", "Sub Zone", "Qty On Hand", "Move Date", "Condition Code"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Custom.1",{"Content", "Name", "Custom"}),
#"Added Custom2" = Table.AddColumn(#"Removed Columns", "Custom_Zone", each if [Sub Zone] = "EURO" and [Location Zone]="50PIC01" then "LLOP" else
if Text.Start([Sub Zone],4) = "MEZZ" and [Location Zone]="50PIC01" then "MEZZ" else
if Text.Start([Sub Zone],4) = "BULK" and [Location Zone]="40BLK01" then "BULK" else
if Text.Start([Sub Zone],4) = "MACH" and [Location Zone]="40BLK01" then "BULK" else
if Text.Start([Sub Zone],4) = "ACID" and [Location Zone]="40BLK01" then "BULK" else
if Text.Start([Sub Zone],3) = "AIR" and [Location Zone]="50PIC01" then "AIR" else
if Text.Start([Sub Zone],3) = "LSS" and [Location Zone]="50PIC01" then "LLOP" else
if Text.Start([Sub Zone],3) = "LSS" and Text.End([Sub Zone],1)="S" and [Location Zone]="40BLK01" then "HLOP" else

if Text.Start([Sub Zone],4) = "EURO" and [Location Zone]="40BLK01" then "HLOP" else ""),
#"Filtered Rows" = Table.SelectRows(#"Added Custom2", each ([Location Zone] = "40BLK01" or [Location Zone] = "50PIC01")),
#"Duplicated Column" = Table.DuplicateColumn(#"Filtered Rows", "Location", "Location - Copy"),
#"Renamed Columns" = Table.RenameColumns(#"Duplicated Column",{{"Location - Copy", "Rawdata"}})
in
#"Renamed Columns"
 
Upvote 0
first: use CODE tags for your code
second: post your source/sources data (change to generic if needed)
 
Upvote 0
I tried with code tag in coding , and Individual steps one by one by adding custom column 1st steps process correctly
1. Text.Select([Rawdata],{"0".."9"})),
In 2nd second steps by adding custom column
2. Text.Length([Rawdata]), Int64.Type) spelling error while everything looks correct
 
Upvote 0
use code tags means [CODE]Your code[/CODE]
eg,
Code:
your code
don't copy code from the post above but from Advanced Editor then use code tags
 
Last edited:
Upvote 0
Ok i got it found 1 problem in Rich Solution

it should be DAM

DAM001DA
 
Upvote 0
Glad you solve it
but
that is why I always asking about representative example source data and expected result because in this case how do I know it was reason of error?
it is a good habit to post source data and expected result in copyable form but not a picture
 
Upvote 0
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
TS = Table.AddColumn(Source, "Number", each Text.Select([Rawdata],{"0".."9"})),
TBD = Table.AddColumn(TS, "TBD", each try Text.BeforeDelimiter([Rawdata], [Number]) otherwise [Rawdata], type text),
RC = Table.RemoveColumns(TBD,{"Number"})
in
RC
 
Upvote 0
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
TS = Table.AddColumn(Source, "Number", each Text.Select([Rawdata],{"0".."9"})),
TBD = Table.AddColumn(TS, "TBD", each try Text.BeforeDelimiter([Rawdata], [Number]) otherwise [Rawdata], type text),
RC = Table.RemoveColumns(TBD,{"Number"})
in
RC
you need to check "your" solution
extract.png

see post #2 then post #5 :cool:
 
Last edited:
Upvote 0
Aditya_Shanmugham

Still problem in line 7

Split text & number power query.xlsx
EF
1Result
2RawdataCustom
3AD102201AAD
4AIRLAIRL
5AP0332010BAP
6ARILS78ARILS
7DD3403A1DD3403A1
8DD0101ADD
9DAM001DAM
Sheet3
 
Upvote 0

Forum statistics

Threads
1,223,786
Messages
6,174,547
Members
452,571
Latest member
MarExcelTips

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top