Forum Discussion

CJ_96601's avatar
CJ_96601
Helper V
4 years ago
Solved

Extract certain text

Need help to extract as per below example:   Date Required Result E1 E1 E2 E2 E3 E3 M2 2 EE.1 1 EE.2 2 EE.11 11 M11 11   If data is E1, E2 and E3, all will ...
  • v-luwang-msft's avatar
    v-luwang-msft
    4 years ago

    Hi CJ_96601 ,

    Adjust to the below:

    if Text.Contains([Date], ".0") 
              then Text.AfterDelimiter([Date], ".0") 
    else if  Text.Contains([Date], ".") 
              then Text.AfterDelimiter([Date], ".")       
    else if Text.Start([Date],1) = "E" and not Text.Contains([Date], ".")  
              then Text.Start([Date],2)
              else 
             Text.Combine(List.RemoveNulls(List.Transform(Text.ToList([Date]),each if Value.Is(Value.FromText(_), type number) then _ else null)))

     

     

    Best Regards

    Lucien

  • v-luwang-msft's avatar
    v-luwang-msft
    4 years ago

    Hi CJ_96601 ,

    New custom column like below:

    = Table.AddColumn(#"Added Custom", "Custom.1", each if not Text.Contains([Date], ".")  then Text.Range([Date],Text.Length([Date])-1,1) 
     else if  Text.Contains([Date], ".")  and Text.Range([Date],1,1)="X" then "X" 
    else Text.Start([Date],1))

     

    Best Regards

    Lucien