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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Search and assemble cell values into new column

Hi all,

 

I need help to search and cut out values from a cell and assemble them in a new row.

I have a semicolon as separator and I need always the first string until an slash (in case an semicolon exists then next needed value would be after the semicolon until the next slash).

In case the values (if there are multiple - separated by semicolon) are same, then write only once in the new column (2nd row in example).

 

Visualized should it look like this:

IsToBe
Enterprise Support/ Information Management;Procurement & Logistics/ Supplier CM/ Supplier Identification; Production/ MaintanenceEnterprise Support, Procurement & Logistics, Production
Enterprise Support/ Information Management;Enterprise SupportEnterprise Support
Finance & ControllingFinance & Controlling

 

Thanks in advance!

2 REPLIES 2
Anonymous
Not applicable

Thanks a lot for your investigation! But it does not work on my side...

1. The search for "/" seems not to work

2. The case without / is not handled.

 

Marko13_0-1664357388916.png

 

Have you any Input for me?

 

Thanks in advance, Marko

 

v-shex-msft
Community Support
Community Support

HI @Anonymous,

You can add a custom column with a custom function to achieve your requirement:

 

    #"Added Custom" = Table.AddColumn(#"Changed Type", "ToBe", each 
            Function.Invoke((x as list)=> 
                let
                    Replaced= 
                        if List.Count(x) > 1 
                        then List.RemoveNulls(List.Transform(x, each 
                            if Text.Contains(_,"/") 
                            then Text.Start(_, Text.PositionOf(_,"/")) 
                            else null )) 
                        else x,
                    Result =Text.Combine(Replaced,",")
                in 
                    Result
            ,{List.Distinct(Text.Split([Is],";"))} ))

 

Result:

1.PNG

Full query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lc4xC4NADAXgvxJuLigdujhKC0KFgqO94TijBDSRmPv/vR4UCp26vcDLxxtHd2VD3ZUOhCHtu6hV0PEsugUjYegDhwU3ZGseKjFpyfBMdX2+wF0WOoziUZXvlVCh7b+ObsptmikWrYFsTCm+c5VpYguMHNH5019TfqtFuBGHrH3WtcKmsq7Ei/P+BQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Is = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Is", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "ToBe", each 
            Function.Invoke((x as list)=> 
                let
                    Replaced= 
                        if List.Count(x) > 1 
                        then List.RemoveNulls(List.Transform(x, each 
                            if Text.Contains(_,"/") 
                            then Text.Start(_, Text.PositionOf(_,"/")) 
                            else null )) 
                        else x,
                    Result =Text.Combine(Replaced,",")
                in 
                    Result
            ,{List.Distinct(Text.Split([Is],";"))} ))
in
    #"Added Custom"

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors