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
JS
Helper II
Helper II

Delimiting with Conditions

Hello. 

 

Is there anyway I can delimit a column based on a condition with another column. 

 

Example. 

 

Team                 Summary 

   A         This is an example - 100

   B         This is not an example - 200

   A         Hello - 500
   C         This is an example - 150

 

I only want to delimit the Summary column with "-" where team = A. 

 

Thanks in advance! 

 

JS

 

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

Hi @JS,

Create the following columns in your table.

FirstCol = IF(Table1[Team ]="A",LEFT(Table1[Summary],FIND("-",Table1[Summary])-1),Table1[Summary])
SecondCol = IF(Table1[Team ]="A",REPLACE(Table1[Summary],1,FIND("-",Table1[Summary]),""),Table1[Summary])
1.PNG


Regards,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Lydia. 

 

I have tried - but I receive the following error message. "The search Text provided to function 'FIND' could not be found in the given text." Any idea what is wrong? 

 

Many thanks! 

Hi  @JS,

Everything works as expected when I use your sample data. Do you copy the "-" from your column to FIND function? Would you mind sharing me your PBIX file so that I can troubleshoot?

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Power Query is the more appropriate tool for these kinds of transformations.

 

My suggstion would be to split the table in team A and other teams, split the column for team A and combine the 2 parts back tiogether.

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Typed1 = Table.TransformColumnTypes(Source,{{"Team", type text}, {"Summary", type text}}),
    FilteredA = Table.SelectRows(Typed1, each ([Team] = "A")),
    Splitted = Table.SplitColumn(FilteredA, "Summary", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Summary.1", "Summary.2"}),
    Typed2 = Table.TransformColumnTypes(Splitted,{{"Summary.1", type text}, {"Summary.2", Int64.Type}}),
    Renamed = Table.RenameColumns(Typed2,{{"Summary.1", "Summary"}}),
    FikteredNotA = Table.SelectRows(Typed1, each [Team] <> "A"),
    Combined = Table.Combine({Renamed,FikteredNotA})
in
    Combined

 

Specializing in Power Query Formula Language (M)

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.