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

all combination of a column

Hello all,

Recently I am trying to solve this problem but could not way to find it, I decided to post it here as my first post. I hope there is a way to do this in PowerBi.

I have a table with two columns that show the Group name and email address.

 

1.png

 

I want to reshape this data to use it in a chord visual. For that visual, I need a new table with three-column "to, from, the value".

I would like to see something like this.

 

2.png 


To and From column will be all combinations of Group names and the Value column will be the number of common people across Groups.

Thank you and best regards


1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

One way to do that is as follows

 

Make a crossjoin table to get all the combinations of Group Name with

 

CJ =
CROSSJOIN (
    SELECTCOLUMNS (
        'Group',
        "To", 'Group'[Group Name]
    ),
    SELECTCOLUMNS (
        'Group',
        "From", 'Group'[Group Name]
    )
)

 

Then make a table visual with the From and To columns from that table, and use this measure, replace Group with your actual initial table name.

 

Count From To =
VAR vFrom =
    SELECTEDVALUE ( CJ[From] )
VAR vTo =
    SELECTEDVALUE ( CJ[To] )
RETURN
    COUNTROWS (
        FILTER (
            VALUES ( 'Group'[Email Address] ),
            CALCULATE (
                DISTINCTCOUNT ( 'Group'[Group Name] ),
                'Group'[Group Name] = vFrom
                    || 'Group'[Group Name] = vTo
            ) = 2
        )
    )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
Anonymous
Not applicable

To get all possibilities you can import the "to" column as a table and import the "from" column as a second table. Then merge to get all possible combinations. 

mahoneypat
Employee
Employee

One way to do that is as follows

 

Make a crossjoin table to get all the combinations of Group Name with

 

CJ =
CROSSJOIN (
    SELECTCOLUMNS (
        'Group',
        "To", 'Group'[Group Name]
    ),
    SELECTCOLUMNS (
        'Group',
        "From", 'Group'[Group Name]
    )
)

 

Then make a table visual with the From and To columns from that table, and use this measure, replace Group with your actual initial table name.

 

Count From To =
VAR vFrom =
    SELECTEDVALUE ( CJ[From] )
VAR vTo =
    SELECTEDVALUE ( CJ[To] )
RETURN
    COUNTROWS (
        FILTER (
            VALUES ( 'Group'[Email Address] ),
            CALCULATE (
                DISTINCTCOUNT ( 'Group'[Group Name] ),
                'Group'[Group Name] = vFrom
                    || 'Group'[Group Name] = vTo
            ) = 2
        )
    )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thank you, Pat!  This is exactly what I wanted to have!

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.