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
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. 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors