- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

In Operator in power Query
Hi,
I want to make a custom filter if a column has certain values: If column = "A" or column = "B" or column ="C" then "filter" else "not filter".
Is there an IN operator, if column IN {"A","B","C"} in M Language/Power Query?
Many thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below. You can use List.Contains( ) to do it.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzmDSRSk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Letter = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each if List.Contains({"A", "B"}, [Letter]) then "Y" else "N")
in
#"Added Custom"
Pat
Did I answer your question? Mark my post as a solution! Kudos are also appreciated!
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@mahoneypa HoosierBI on YouTube
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

how are you populating the table with A B C & D? I have figured out almost everything else from your M-Code but that.
your code
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzmDSRSk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Letter = _t]), #"Added Custom" = Table.AddColumn(Source, "Custom", each if List.Contains({"A", "B"}, [Letter]) then "Y" else "N") in #"Added Custom"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below. You can use List.Contains( ) to do it.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzmDSRSk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Letter = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each if List.Contains({"A", "B"}, [Letter]) then "Y" else "N")
in
#"Added Custom"
Pat
Did I answer your question? Mark my post as a solution! Kudos are also appreciated!
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@mahoneypa HoosierBI on YouTube

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
09-10-2024 07:35 AM | |||
08-21-2024 06:40 AM | |||
08-29-2024 03:34 AM | |||
05-02-2024 09:12 AM | |||
07-11-2024 09:37 AM |
User | Count |
---|---|
117 | |
99 | |
84 | |
53 | |
47 |