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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
passants
Frequent Visitor

New Table with OR Logic from Multiple Columns

Hello,

I would like to make a new table in the Power Query step based on OR logic referencing multiple columns from the original table, and have not been able to figure out how to do so.

 

For example, my original table is as follows:

 

PersonIDMajor1Major2
10000A 
20000BA
30000A 
40000CB

 

I would like to make a new table of rows with the logic that if major1=A OR major2=A, then include the row in that table.

 

In the actual data, I would be referencing close to 50 columns, so simply creating a new Conditional Column with the logic and then filtering the new table based on the Conditional Column would not be practical. So, essentially I'm looking for a way in the M code to say =OriginalTable IF Major1=A OR Major2=A.

 

Thank you!

1 ACCEPTED SOLUTION
passants
Frequent Visitor

I solved my own question after playing around with it for awhile:

 

In PowerQuery, I created the new table as a copy of the old table. Then, I filtered the column Major 1 to =A to generate the code for the step as follows:

 

= Table.SelectRows(#"Added Conditional Column", each ([Major 1] = "A"))

 

Then in the Advanced Editor, changed it to the following:

 

= Table.SelectRows(#"Added Conditional Column", each [Major 1] = "A" or [Major 2] = "A")

 

which left me with a table of the rows I needed. 

View solution in original post

5 REPLIES 5
passants
Frequent Visitor

I solved my own question after playing around with it for awhile:

 

In PowerQuery, I created the new table as a copy of the old table. Then, I filtered the column Major 1 to =A to generate the code for the step as follows:

 

= Table.SelectRows(#"Added Conditional Column", each ([Major 1] = "A"))

 

Then in the Advanced Editor, changed it to the following:

 

= Table.SelectRows(#"Added Conditional Column", each [Major 1] = "A" or [Major 2] = "A")

 

which left me with a table of the rows I needed. 

vanessafvg
Super User
Super User

you could also unpivot all the columns you want to place the filter on and then do conditional formatting, then pivot them again?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




unless you can filter excel directly easily, i would unpivot all the columns you want to place the filter on and then do conditional column, then pivot them again?

 

see example attached with pbix

 

vanessafvg_0-1647635377634.png

 

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




vanessafvg
Super User
Super User

what is the source of the table in M?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




The original table is an Excel Workbook, so:
= Excel.Workbook(File.Contents("[File Path]"), null, true)

 

Unpivoting would create a ton of excess columns as there are quite a few different values, so I was also hoping to avoid that.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors