Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Power Query : Extract text before delimiter with condition

Hi,

 

I have the Name column and would like to extract it as the Expecting Name (Result): 

 

NameExpecting Name 
AZER.SDDAZER
AZEDT.FVAZEDT
AZERZ.cFSAZERZ
VSFS.DFSVSFS
12.12.1212.12.12
12.3412.34
VSD.ZREVSD
DFS.RFDFS
12.23412.234

 If name starts by 12 , Expecting Name = Name

IF name starts by letter, expecting name  = text before the first delimiter

 

Thank you in advance for your help.

Tg

 

 

  • Hi Anonymous ,

     

    Do the TextBeforeDelimiter option and then change the code to:

    = Table.AddColumn(Source, "Text Before Delimiter", each if Text.Start([Name], 2) = "12" then [Name] else Text.BeforeDelimiter([Name], "."), type text)

     

    Has you can see the part of the split is updated to an IF statement:

     

     

2 Replies

  • Hi Anonymous ,

     

    Do the TextBeforeDelimiter option and then change the code to:

    = Table.AddColumn(Source, "Text Before Delimiter", each if Text.Start([Name], 2) = "12" then [Name] else Text.BeforeDelimiter([Name], "."), type text)

     

    Has you can see the part of the split is updated to an IF statement:

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for your help