Forum Discussion

uayan's avatar
uayan
Frequent Visitor
4 years ago
Solved

Extract text from cell if any.

I have a column like that. 

AB1 xx yy zz
yy xx zz AB2
xx yy zz AB1
xx yy yy zz
xx yy zz zz AB3

I want to create calculated column and need formula that

If there is AB1 value, type AB1,

If there is AB2 value, type AB2,

If there is AB3 value, type AB3,

If there is no ABx value, type "No value"


This should be the result...

AB1
AB2
AB1
No value
AB3
  • uayan's avatar
    uayan
    4 years ago
    I have solved like that
     
    Column = SWITCH(TRUE(),SEARCH("AB1",Sheet[Labels],,0)>1, "AB1",SEARCH("AB2",Sheet1[Labels],,0)>1,"AB2","No Value")

2 Replies

  • uayan , Try to use Text.Split and List.Select with or condition

    a new column in power query

    Text.Combine(List.Select(Text.Split([Column], each Text.Contains(_, "AB") ), ",")

    • uayan's avatar
      uayan
      Frequent Visitor
      I have solved like that
       
      Column = SWITCH(TRUE(),SEARCH("AB1",Sheet[Labels],,0)>1, "AB1",SEARCH("AB2",Sheet1[Labels],,0)>1,"AB2","No Value")