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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Count combinations of different columns that contain values

I have this example data set and want to be able to create a table which has the combinations of all the different columns

Col1Col2Col3Col4
TrueTrueTrue 
 TrueTrueTrue
TrueTrueTrueTrue
True   
 TrueTrueTrue
 TrueTrue 

The required output would be:

 

CombinationsCount
Col1, Col2, Col31
Col2, Col3, Col42
Col1, Col2, Col3, Col41
Col11
Col2, Col31

 

Is there a way I can do this using PowerBI?

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous ,

 

In addition to Greg_Deckler 's reply, after you do some transformation in Power Query Editor. I think your table will look like as below.

RicoZhou_0-1669877300649.png

Then you can create calculated columns to achieve your goal.

Combinations =
CONCATENATEX (
    FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) ),
    'Table'[Attribute],
    ","
)

Create a table visual by [Combinations] column and distinct count index column.

Result is as below.

RicoZhou_1-1669877574111.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous ,

 

In addition to Greg_Deckler 's reply, after you do some transformation in Power Query Editor. I think your table will look like as below.

RicoZhou_0-1669877300649.png

Then you can create calculated columns to achieve your goal.

Combinations =
CONCATENATEX (
    FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) ),
    'Table'[Attribute],
    ","
)

Create a table visual by [Combinations] column and distinct count index column.

Result is as below.

RicoZhou_1-1669877574111.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Anonymous
Not applicable

This is perfect thank you. Is there a way of having a combination of "Empty", if there is no value for Col1, Col2, Col3 or Col4?

Greg_Deckler
Super User
Super User

@Anonymous Probably best to add an Index in Power Query Editor and then unpivot your 4 columns. Then this is a much easier solve I think. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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