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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
leahschneider
Helper III
Helper III

Filter on Multiple Columns

I have a table with data like this:

IdCol1Col2
1AB
2AA
3CA
4BA
5CC

I need to make an AB filter that filters for everything that has A or B in both columns. So I want only rows 1,2 and 4. These groupings will change and be added to over time, like adding an AD filter (which would return nothing from this table) or an ABC filter (which would return everything from this table). I'm not sure how to go about setting this up.

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here is a measure expression that shows one way to do it. I hard coded in A and B, but you could get them dynamically with a disconnected table slicer with the desired values (and store the VALUES of that column used in slicer in another variable, to replace the hard-coded tables).

 

Has AB in Both =
VAR col1 =
    MIN( T1[Col1] IN { "A", "B" }
VAR col2 =
    MIN( T1[Col2] IN { "A", "B" }
RETURN
    IFcol1 && col2, )

 

Pat

 

mahoneypat_0-1647387687051.png





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


View solution in original post

6 REPLIES 6
AliceFGX
Frequent Visitor

@mahoneypat thanks for your solution, could you please explain how to :

" get them dynamically with a disconnected table slicer with the desired values (and store the VALUES of that column used in slicer in another variable, to replace the hard-coded tables)." ?

I need to let the users select different countries in a slicer than use it to search different columns with countries in it and filter the rows that show the selected countries in any column. It is nearly the same as in this post, as if A and B were countries, but I have to let people choose.

mahoneypat
Microsoft Employee
Microsoft Employee

Here is a measure expression that shows one way to do it. I hard coded in A and B, but you could get them dynamically with a disconnected table slicer with the desired values (and store the VALUES of that column used in slicer in another variable, to replace the hard-coded tables).

 

Has AB in Both =
VAR col1 =
    MIN( T1[Col1] IN { "A", "B" }
VAR col2 =
    MIN( T1[Col2] IN { "A", "B" }
RETURN
    IFcol1 && col2, )

 

Pat

 

mahoneypat_0-1647387687051.png





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


rsbin
Community Champion
Community Champion

@leahschneider,

First create a new Calculated Column which concatenates your two columns:

ComboColumn = Column1 & Column2

You can then use this new column as a filter. 

But I would take it one step further and create a new Dimension Table which would include all your possible combinations.  You can do this in Excel and import it, or use the Enter Data option.

Create a relationship (1: many) between this new Dimension Table and your data table above.  Then use this Dimension table in your Slicer.

Hope this helps.

 

In my real situation there are thousands of combinations and might be more in a growing database. Additionally, as I mentioned, I might want to select group AB or I might want to select group ABC which would include all posibilities with A B or C in both columns. I may also want to select group ABCDEF. This is a fairly large dataset with a lot of permutations and I'm not going to ever be able to specify everything out manually.

@leahschneider,

I would create two dimension tables - one for Column1 and one for Column2.

Table1 = SummarizeColumns(YourTable[Column1]) and
Table2 = SummarizeColumns(YourTable[Column2])

(My syntax might not be perfect for this, but should get you close)

These tables will then grow as your data grows.

Then simply create your two slicers from each of these tables.

In Selection Controls, I would enable both the Multi-select and Select All options.

This should then cover all your potential combinations.

I can't see any other way of doing this other than creating 2 slicers.

Thank you but I can't see any way except by using two slicers either which is why I asked this question.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.