cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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:

 Product Region Main Seller Support Seller 1 West Alex Pedro 2 East Stephanie Alex 3 North Pedro 4 North Stephanie Pedro 5 South Pedro Alex 6 South Pedro Alex 7 South Alex Stephanie

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.

Regards,

RobGer

1 ACCEPTED SOLUTION
Super User

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]
)

Proud to be a Super User!

8 REPLIES 8
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
)``````

 Expertise = List.Accumulate(        {Days as from Today},        {Skills and Knowledge},        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday))

Super User

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

Super User

Hi,

CombinedName =
IF(
'Sales'[Main] <= 'Sales'[Supporter],
'Sales'[Main] & " " & 'Sales'[Supporter],
'Sales'[Supporter] & " " & 'Sales'[Main]
)

PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Super User

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]
)

Proud to be a Super User!

Super User

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:

Proud to be a Super User!

Frequent Visitor

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.

Super User

Hi,

Rank =

RANKX(
CROSSJOIN(
ALL(Sales[Main]),
ALL(Sales[Supporter])),
Sales[SalesAmount]
)

PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Frequent Visitor

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.

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

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

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors