Get Position of First Text Char in Number & Text mixed String Power Query

radonwilson

New Member
Joined
Jun 23, 2021
Messages
49
Office Version
  1. 2019
Platform
  1. Windows
1. How to get the positions of the first text char in a mixed string?

Master_Order_Report.xlsx
AB
7Files NamesOutput (position of first text char)
81112. Orders6
92451 2 . Refunds9
10#784&@ . Cancellation9
Sheet1
Cell Formulas
RangeFormula
B8B8=SEARCH("O",A8)-1
B9B9=SEARCH("R",A9)-1
B10B10=SEARCH("C",A10)-1


2. How to use these splitter functions with Text.Split() . I want to split the text and keep that in a list in Custom Column.
1690090932465.png


For Example, if there is a word "Sweet" I want to split it by the number of characters as 1 and keep that in a list {S,w,e,e,t}
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Text.ToList is what you need
 
Upvote 0
Solution
Here is one way for first item. I think JEC has offered up the solution for the last sentence requested.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Files Names", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Files Names.1", "Files Names.2"}),
    #"Added Custom" = Table.AddColumn(#"Split Column by Delimiter", "Custom", each Text.Length([Files Names.1])+1),
    #"Inserted Merged Column" = Table.AddColumn(#"Added Custom", "Merged", each Text.Combine({[Files Names.1], [Files Names.2]}, " "), type text),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Merged Column",{"Files Names.1", "Files Names.2"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Merged", "Custom"})
in
    #"Reordered Columns"
 
Upvote 0
Another way for #1 (since #2 is already answered and this method also uses Text.ToList() that explains how it works):
(Assumption from the sample: Text character = Letters: A to Z and a to z)
Power Query:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0NNJT8C9KSS0qVorViVYyMjE1VDBS0FMISk0rzUuBCCqbW5ioOQAFnRPzklNzchJLMvPzlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Files Names" = _t]),
    // Used binary data as the Source for testing purposes.
    // Delete the previous Source line and set up your source as you need, i.e. from a table/range, as shown below.
    // Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Result = Table.AddColumn(Source, "Output (position of first text char)",
                each List.PositionOf(
                    List.Transform(
                            Text.ToList(_[Files Names]),
                            each List.Contains({"A".."Z"}, Text.Upper(_))
                        ),
                        true
                    )
                )
in
    Result
The result:
Files NamesOutput (position of first text char)
1112. Orders6
2451 2 . Refunds9
#784&@ . Cancellation9
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,687
Members
449,117
Latest member
Aaagu

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