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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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