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
Sasha
Helper III
Helper III

Comparing field to itself

I have the following data about ownership of barbers in three barber shops

enter image description here

I'm interested presenting a matrix on PBI where the rows are barbers that are owners in at least one barber shop and the columns are all barbers. Each cell in the matrix to represent relationship between the barbers when they're owners and the rest of the barbers. If two barbers own a barbershop their relationship is "owners" even if other barber shop one of them is tenant. If the second barber is always a tenant in owner's barber shop than it's a owner-tenant relationship. Same barber is "same person". Any other relationship remains blank.

I expect the following result:

enter image description here

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

@Sasha ,

 

Drag [Barber] from Table2 to Rows and add measure below.

Table2 =
FILTER ( Table1, Table1[Status] = "Owner" )
Measure =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( Table2[Barber] ) = SELECTEDVALUE ( Table1[Barber] ), "Same Person",
    NOT (
        ISEMPTY (
            FILTER (
                Table1,
                Table1[BarberShop] IN VALUES ( Table2[BarberShop] )
                    && Table1[Status] = "Owner"
            )
        )
    ), "Owners",
    NOT (
        ISEMPTY (
            FILTER ( Table1, Table1[BarberShop] IN VALUES ( Table2[BarberShop] ) )
        )
    ), "Owner-Tenant"
)
Community Support Team _ Sam Zha
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-chuncz-msft
Community Support
Community Support

@Sasha ,

 

Drag [Barber] from Table2 to Rows and add measure below.

Table2 =
FILTER ( Table1, Table1[Status] = "Owner" )
Measure =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( Table2[Barber] ) = SELECTEDVALUE ( Table1[Barber] ), "Same Person",
    NOT (
        ISEMPTY (
            FILTER (
                Table1,
                Table1[BarberShop] IN VALUES ( Table2[BarberShop] )
                    && Table1[Status] = "Owner"
            )
        )
    ), "Owners",
    NOT (
        ISEMPTY (
            FILTER ( Table1, Table1[BarberShop] IN VALUES ( Table2[BarberShop] ) )
        )
    ), "Owner-Tenant"
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft  how can I sort the columns of the output in my example so all the the barbers that have "the same" person will appear first similarly to the order they appear in the rows and only after that the rest barbers (that basically only rent) will appear in the columns. In this case, the diagonal will be continuous and this will obviously be more pleasing visually. 

Awesome!

Thanks!

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.