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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
RobGer
Frequent Visitor

Ranking by combination of two columns

Dear PowerBI Community,

 

I have the following question, hopefully you can help me with this.

 

I have a table for each product sold. It looks like this:

 

ProductRegionMain SellerSupport Seller
1WestAlexPedro
2EastStephanieAlex
3NorthPedro 
4NorthStephaniePedro
5SouthPedroAlex
6SouthPedroAlex
7SouthAlexStephanie

 

I would like to calculate an rank the top seller combinations, independent of if they supported during the sale, or if they were the main seller. 

 

The desired result would be displayed on a table with a ranking. 

 

In this example, the combination "Alex and Pedro" would appear 3 times, and ranked as first. "Stephanie and Alex" would be ranked second, and the rest would follow with only one count ("Stephanie and Alex").

 

I don´t wish to display the sales, where there is no support seller, but I believe I can filter that out later through the filter pane and setting "Support Seller" to not allowing blanks.

 

Thank you for your help in advance!

 

Regards,

RobGer

1 ACCEPTED SOLUTION
amustafa
Solution Sage
Solution Sage

Stange request, anyhow...change the Seller Combination as following.

 

Seller Combination =
IF(
    SalesTable[Main Seller] < SalesTable[Support Seller],
    SalesTable[Main Seller] & ", " & SalesTable[Support Seller],
    SalesTable[Support Seller] & ", " & SalesTable[Main Seller]
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

8 REPLIES 8
ThxAlot
Super User
Super User

 

Interesting, this seemly easy question turns out to be brain teaser.

 

Rnk = 
RANKX(
    ALLSELECTED( PAIR[Product] ),
    VAR __prod = CALCULATETABLE( VALUES( PAIR[Product] ), ALLEXCEPT( PAIR, PAIR[Product] ) )
    VAR __main = CALCULATE( MAX( PAIR[Main Seller] ), ALL(), __prod )
    VAR __sup = CALCULATE( MAX( PAIR[Support Seller] ), ALL(), __prod )
    RETURN
        CALCULATE(
            COUNTROWS( PAIR ),
            TREATAS( { ( __main, __sup ) }, PAIR[Main Seller], PAIR[Support Seller] )
        )
            + CALCULATE(
                COUNTROWS( PAIR ),
                ALL( PAIR[Product] ),
                TREATAS( { ( __sup, __main ) }, PAIR[Main Seller], PAIR[Support Seller] )
            ),
    COUNTROWS( PAIR )
        + CALCULATE(
            COUNTROWS( PAIR ),
            TREATAS(
                { ( MAX( PAIR[Support Seller] ), MAX( PAIR[Main Seller] ) ) },
                PAIR[Main Seller],
                PAIR[Support Seller]
            )
        ),
    ,
    DENSE
)

 

ThxAlot_0-1706124155629.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Ahmedx
Super User
Super User

to get a suitable model you need to create tables in Power Query.
please look at the file and study it

Screenshot_1.pngScreenshot_2.pngScreenshot_3.pngScreenshot_4.pngScreenshot_5.pngScreenshot_6.png

olgad
Super User
Super User

Hi, 

CombinedName =
IF(
    'Sales'[Main] <= 'Sales'[Supporter],
    'Sales'[Main] & " " & 'Sales'[Supporter],
    'Sales'[Supporter] & " " & 'Sales'[Main]
)
olgad_0-1706097382874.png

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime
amustafa
Solution Sage
Solution Sage

Stange request, anyhow...change the Seller Combination as following.

 

Seller Combination =
IF(
    SalesTable[Main Seller] < SalesTable[Support Seller],
    SalesTable[Main Seller] & ", " & SalesTable[Support Seller],
    SalesTable[Support Seller] & ", " & SalesTable[Main Seller]
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amustafa
Solution Sage
Solution Sage

Hi @RobGer 

 

Based on your sample dataset, I would create 1 calculated column and 2 measures.

 

Seller Combination = SalesTable[Main Seller] & " and " & SalesTable[Support Seller]
 
Seller Combination Count =
CALCULATE(
    COUNTROWS(SalesTable),
    ALLEXCEPT(SalesTable, SalesTable[Seller Combination])
)
 
Seller Combination Rank =
RANKX(
    ALL(SalesTable[Seller Combination]),
    [Seller Combination Count],
    ,DESC,
    Dense
)
 
Results:
 
amustafa_0-1706086855378.png

If I answered your question, please mark this thread as accepted.
Follow me on LinkedIn:
https://www.linkedin.com/in/mustafa-ali-70133451/

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @amustafa ,

 

this is looking good, I would need the combinations to be added together, in this case, "Pedro and Alex" would count the same as "Alex and Pedro". I don´t know if there is a feasible solution that would allow it.

olgad
Super User
Super User

Hi, 

Rank =

RANKX(
    CROSSJOIN(
        ALL(Sales[Main]),
        ALL(Sales[Supporter])),
        Sales[SalesAmount]
)
olgad_0-1706085820867.png

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime
RobGer
Frequent Visitor

Hi @olgad ,

 

This is looking in the right direction, would it be possible to fuse together the repeated seller combinations? In your example, "Alex and Dana" and "Dana and Alex" would be displayed together (as either "Alex and Dana" or "Dana and Alex") and the "Sales Amount" would be added together, too.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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