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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.