Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

if Statement with conditions from list

Dear community members,

 

Need support in Power Query data transformation.

 

I have a column of Product Type column 

 

Product Type
Books
Furniture
Technology
Office Supplies
Books
Books
Books
Office Supplies
Technology
Office Supplies

 

The objective is to add one conditional column which takes input from a list to return required value

List:

lstPrimeProduct

Furniture
Office Supplies

 

Output:

Product TypePrime Product
Books 
FurnitureY
Technology 
Office SuppliesY
Books 
Books 
Books 
Office SuppliesY
Technology 
Office SuppliesY

 

Please advise.

 

Thanks

vir                                             

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsrPzy5WitWJVnIrLcrLLCktSgXzQlKTM/Lyc/LTK8Fc/7S0zORUheDSgoKczFSIBoRWbCxsOggZGgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product Type" = _t]),
    lstPrimeProduct = {"Furniture", "Office Supplies"},
    #"Added Custom" = Table.AddColumn(Source, "Prime Product", each if List.Contains(lstPrimeProduct,[Product Type]) then "Y" else null)
in
    #"Added Custom"

 

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsrPzy5WitWJVnIrLcrLLCktSgXzQlKTM/Lyc/LTK8Fc/7S0zORUheDSgoKczFSIBoRWbCxsOggZGgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product Type" = _t]),
    lstPrimeProduct = {"Furniture", "Office Supplies"},
    #"Added Custom" = Table.AddColumn(Source, "Prime Product", each if List.Contains(lstPrimeProduct,[Product Type]) then "Y" else null)
in
    #"Added Custom"

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors