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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
patrickmlsk
Frequent Visitor

Filter multiple columns with one column

Hello,

 

I am relatively new to Power BI and encountered a problem with filtering multiple columns via one single column. My table is like the following:

 

Spoiler
Dateemailnumbercolumn Acolumn Bcolumn Ccolumn D
01.01.2019test@test.com1BlueGreenYellowBlack
02.01.2019test@test.com2PinkWhiteOrangeGreen
03.01.2019test@test.com3BlackBlueGreenYellow
04.01.2019test@test.com4BlueBlackGreenYellow
05.01.2019test@test.com5WhiteBlackPinkOrange
06.01.2019test@test.com5YellowGreenBlackWhite
07.01.2019test@test.com6BlackYellowBluePink
08.01.2019test@test.com8BlueGreenYellowBlack
09.01.2019test@gmail.com7PinkWhiteOrangeGreen
10.01.2019test@gmail.com9BlackBlueGreenYellow
11.01.2019test@gmail.com1BlueBlackGreenYellow
12.01.2019test@gmail.com2WhiteBlackPinkOrange
13.01.2019test@gmail.com3YellowGreenBlackWhite
14.01.2019test@gmail.com4BlackYellowBluePink
15.01.2019test@gmail.com5BlueGreenYellowBlack
16.01.2019test@gmail.com6PinkWhiteOrangeGreen
17.01.2019test@gmail.com7BlackBlueGreenYellow
18.01.2019test@gmail.com324BlueBlackGreenYellow
19.01.2019test@gmail.com3WhiteBlackPinkOrange
20.01.2019test@gmail.com3YellowGreenBlackWhite
21.01.2019test@gmail.com5BlackYellowBluePink
22.01.2019test@gmail.com3BlueGreenYellowBlack
23.01.2019test@gmail.com3PinkWhiteOrangeGreen
24.01.2019test@gmail.com3BlackBlueGreenYellow
25.01.2019testtest@gmail.com4BlueBlackGreenYellow
26.01.2019testtest@gmail.com34WhiteBlackPinkOrange
27.01.2019testtest@gmail.com3YellowGreenBlackWhite
28.01.2019testtest@gmail.com3BlackYellowBluePink
29.01.2019testtest@gmail.com3BlueGreenYellowBlack
30.01.2019testtest@gmail.com3PinkWhiteOrangeGreen
31.01.2019testtest@gmail.com3BlackBlueGreenYellow
01.02.2019testtest@gmail.com4BlueBlackGreenYellow
02.02.2019testtest@gmail.com5WhiteBlackPinkOrange
03.02.2019testtest@gmail.com3YellowGreenBlackWhite
04.02.2019testtest@gmail.com1BlackYellowBluePink

The rows are always different and also the column A - D won't contain the same value in a row.

 

So I want to display the following:

 

power bi test.png

I want to filter the whole table with the slicer. At this moment I only get the rows that contains the value in column A.

 

Moreover, I want to display the following: 

power bi test 2.jpg

I want to display the number of each value for each column in a matrix. At the moment it is correlated to column A. 

 

Thanks for the help!

1 ACCEPTED SOLUTION
d_gosbell
Super User
Super User

The first thing I would do is create a separate table with a distinct list of colors.

 

You could do this by creating a calculated table with an expression like the following:

Colors = DISTINCT(UNION(DISTINCT(Table1[column A]),DISTINCT(Table1[column B]), DISTINCT(Table1[column C]),DISTINCT(Table1[column D]) ))

Then I would rename the column in this table from [Column A] to simply [Color] as it's no longer directly linked to ColumnA. I would then use this new column in your slicer.

 

Then I would create a measure like the following and put a filter on your table visual where this measure is >= 1

Count All 2 = countrows(Filter(Table1
, Table1[column A] in values(Colors[Color])
|| Table1[column B] in values(Colors[Color])
|| Table1[column C] in values(Colors[Color])
|| Table1[column D] in values(Colors[Color])
))

To achieve your matrix result I would put the Colors[Color] column on the rows then create 4 measures to put on the columns which use expressions like the following (creating one measure for each of columns A, B, C and D):

 

Count A = CALCULATE(countrows(Table1)
, TREATAS(values(Colors[Color]), Table1[column A])
)

 

View solution in original post

1 REPLY 1
d_gosbell
Super User
Super User

The first thing I would do is create a separate table with a distinct list of colors.

 

You could do this by creating a calculated table with an expression like the following:

Colors = DISTINCT(UNION(DISTINCT(Table1[column A]),DISTINCT(Table1[column B]), DISTINCT(Table1[column C]),DISTINCT(Table1[column D]) ))

Then I would rename the column in this table from [Column A] to simply [Color] as it's no longer directly linked to ColumnA. I would then use this new column in your slicer.

 

Then I would create a measure like the following and put a filter on your table visual where this measure is >= 1

Count All 2 = countrows(Filter(Table1
, Table1[column A] in values(Colors[Color])
|| Table1[column B] in values(Colors[Color])
|| Table1[column C] in values(Colors[Color])
|| Table1[column D] in values(Colors[Color])
))

To achieve your matrix result I would put the Colors[Color] column on the rows then create 4 measures to put on the columns which use expressions like the following (creating one measure for each of columns A, B, C and D):

 

Count A = CALCULATE(countrows(Table1)
, TREATAS(values(Colors[Color]), Table1[column A])
)

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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