Forum Discussion

alwright's avatar
alwright
New Member
2 years ago
Solved

If left starts with this, return this

Very new to Power BI and Power Query.  I have a column A with values that look like this: (0102) and (0506), etc.  I want a column B labled "Region" where, if column A starts with "(01" then column B spits out "Region 1".  If column A is "(05", then column B is "Region 5".  How would I do that?

 

Thank you.

  • Hi, I try to explain as simple as possible:

     

    A.) Extract fisrt 2 characters

    Enter 2

     

    B.) 

     

     

     

4 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Icon for Most Valuable Professional rankMost Valuable Professional

    Put following formula in a custom column

    [a = Text.ToList([Column A]), b = if a{0} = "(" and a{1} = "0" and Value.FromText(a{2}) is number then "Region  " & a{2} else null] [b]
  • dufoq3's avatar
    dufoq3
    Icon for Community Champion rankCommunity Champion

    Hi, I try to explain as simple as possible:

     

    A.) Extract fisrt 2 characters

    Enter 2

     

    B.) 

     

     

     

    • alwright's avatar
      alwright
      New Member

      This was exactly what I was looking for, thank you!  And thank you for keeping it simple, I really appreciate it.