Expression error

Nancymara

New Member
Joined
Apr 15, 2023
Messages
2
Office Version
  1. 2021
  2. 2016
Platform
  1. Windows
So I have this data, I merged, renamed and I’m trying to clean it using the Text.Select( function but it giving me an expression error message like this, I have a deadline to meetup. I would appreciate a effective split to this l. Anticipating

A7F99310-247C-4D2F-81DC-8625B8AA5748.jpeg
 
Last edited by a moderator:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Instead of a picture (which we cannot manipulate), suggest you upload a sample worksheet (8-10 records) showing your data and then manually mock up what your solution should look like. Use XL2BB to upload your data.
 
Upvote 0
Welcome to the MrExcel Message Board!

I don't know when it was actually included but it looks like the Text.Select function was not included in the Power Query version that you are using.

You can get a list of functions by creating a new blank query and entering = #shared as the only formula.

1681593321402.png



As you can see, it exists in the Power Query coming with Excel 365 on my computer.
1681593380390.png
 
Upvote 0
Solution
So you are right about the function not added to the list of functions available on my power query, so how do I get to add the Text.Select function or is there an alternative please. Thank you
 
Upvote 0
If you are working in a PQ version that Text.Select doesn't exist, then you can try using a custom function like the following:
Just replace the Text.Select function in your formula with fnTextSelect with the same arguments.

Power Query:
    fnTextSelect = (txt as text, allowedChars as any ) => 
        let 
            Chars = Text.ToList(txt),
            Filtered = List.Select(Chars, each List.Contains(allowedChars, _)),
            Result = Text.Combine(Filtered)
        in
            Result

Or, if List.Select also doesn't exist, then the following might help:

Power Query:
    fnTextSelect = (txt as text, allowedChars as any ) => 
        let 
            Result = List.Generate(
                () => [i = 0],
                each [i] < Text.Length(txt),
                each [i = [i] + 1],
                each 
                    let 
                        Letter = Text.Middle(txt, [i], 1),
                        Filtered = if List.Contains(allowedChars, Letter) then Letter else null,
                        Result = Text.Combine(List.RemoveNulls(Filtered))
                    in
                        Result
            )
        in
            Result
 
Upvote 0
Note: You can add the custom function into the existing code directly, or set it up separately.

Directly into the single query:
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
 
    #"Changed Type1" = Source, // Use your own code here
   
    Result = Table.AddColumn(#"Changed Type1", "Custom", each fnTextSelect([FullName], {"A".."z", " ", "."})),

    fnTextSelect = (txt as text, allowedChars as any ) =>
        let
            Chars = Text.ToList(txt),
            Filtered = List.Select(Chars, each List.Contains(allowedChars, _)),
            Result = Text.Combine(Filtered)
        in
            Result

in
    Result

Or, if you'd like to use this function in other queries as well, then create a blank query, copy and paste the following code in the Advanced Editor, and name the query as fnTextSelect.

Power Query:
(txt as text, allowedChars as any ) =>
    let
        Chars = Text.ToList(txt),
        Filtered = List.Select(Chars, each List.Contains(allowedChars, _)),
        Result = Text.Combine(Filtered)
    in
        Result
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,614
Members
452,661
Latest member
Nonhle

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