+ Reply to Thread
Results 1 to 2 of 2

If - And Statement in Power Query

  1. #1
    Forum Contributor
    Join Date
    03-03-2011
    Location
    Ottawa, Ontario
    MS-Off Ver
    365
    Posts
    136

    If - And Statement in Power Query

    I have a custom column in power query that shows a value if a word is found in another column. It was working great until a situation came up that threw it off due to the data that can be entered by the user.
    This is the if statement I am currently using: if Text.Contains([Location], "New York ") then "Zone 5" and this works great until it encounters a field with "New York State" or some other combination using New York. Is there a way of making an If/And statement using the M language to evaluate this. I need a statement that will do the following: If Text Contains New York and Doesn't Contain State then Zone 5. I am new to the M language so still trying to get a handle on it.

    Thanks.

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: If - And Statement in Power Query

    Please try

    if Text.Contains([Location], "New York") and not Text.Contains([Location], "State") then "Zone 5"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 10
    Last Post: 06-25-2020, 12:19 AM
  2. [SOLVED] Power Query - excel formula translation into Power Query
    By afgi in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 02-19-2020, 03:38 AM
  3. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  4. [SOLVED] Power Pivot does not load new column added in Power query
    By ibuhary in forum Excel General
    Replies: 12
    Last Post: 02-19-2019, 03:53 AM
  5. [SOLVED] Power Query - One works the other does not (replace with if statement) - Why?
    By learning new things in forum Excel General
    Replies: 13
    Last Post: 08-20-2018, 09:46 PM
  6. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  7. Replies: 0
    Last Post: 04-05-2018, 01:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1