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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Top 10% Supplier Spend by Category

I've been struggling to create a measure that divides the spend of the top 10 suppliers by total spend with good performance when displayed in a bar chart broken down by categories. I've searched online and on this forum and have tried various methods. Below are the measures I've found work the best, but ultimately a bar chart that displays the Top 10 % Supplier Spend by Category & Subcategory takes upwards of 1 minute to display.

 

I can post info from DAX Studio or whatever would be helpful to those who can assist. At this point, I'm leaning towards the design of the data model being what's holding it up. Either that or this type of calculation that uses RANKX can't be done very well with the number of suppliers in the supplier table; it has almost 300 thousand rows.

 

Spend =
SUM(Spend[SpendAmount])

 

Supplier Ranking =
RANKX(ALL('Supplier'[Supplier Name]), Spend[Spend])

 

Top 10 Supplier Spend =
SUMX(
    FILTER(
        VALUES('Supplier Parent'[Global Parent Supplier Name]),
        [Supplier Parent Ranking] <= 10
    ),
    Spend[Spend]
)

 

Have also tried:

Top 10 Supplier Spend =
CALCULATE(
    Spend[Spend],
    TOPN(
        10,
        VALUES('Supplier Parent'[Global Parent Supplier Name]),
        Spend[Spend]
    )
)
 
Top 10% of Total Supplier Spend =
DIVIDE([Top 10 Supplier Spend], Spend[Spend])
3 REPLIES 3
Anonymous
Not applicable

Spend =
SUM(Spend[SpendAmount])

 

Supplier Ranking =
RANKX(ALL('Supplier'[Supplier Name]), Spend[Spend])

 

Top 10 Supplier Spend =
SUMX(
    FILTER(
        VALUES('Supplier Parent'[Global Parent Supplier Name]),
        [Supplier Parent Ranking] <= 10
    ),
    Spend[Spend]
)

 

Have also tried:

Top 10 Supplier Spend =
CALCULATE(
    Spend[Spend],
    TOPN(
        10,
        VALUES('Supplier Parent'[Global Parent Supplier Name]),
        Spend[Spend]
    )
)
 
Top 10% of Total Supplier Spend =
DIVIDE([Top 10 Supplier Spend], Spend[Spend])

 

I'd try to do something like this. Let's say that your ranking itself works fast. Have you tried to rank all your suppliers in DAX Studio? How long does it take? It SHOULD be blazingly fast. I mean a query like this:

evaluate
calculatetable(
	summarizecolumns(
		'Supplier Parent'[Supplier Name],
		"Rank", [Supplier Ranking]
	),
	<some filters here>
)

If this is not blazingly fast, then you have to do ranking by a different means without using RANKX. You can write such ranking all by yourself using calculate and filters.

 

If the ranking is that fast enough, then you could do this:

[Top X Supplier Spend] =
var __topCount = 10 // this could be taken from a disconnected dimension
var __topSuppliers =
	filter(
		// this will be blazingly fast by assumption
		addcolumns(
			values( 'Supplier Parent'[Global Parent Supplier Name] ),
			"SupplierRank", [Supplier Ranking]
		),
		[SupplierRank] <= __topCount
	)
var __result =
	calculate(
		[Spend],
		__topSuppliers
	)
return
	__result

I'd personally use SupplierID (integer) instead of Supplier Name.

 

Best

D

Anonymous
Not applicable

Why are you using the name of a table in front of a measure? This is confusing and very BAD practice.

Best
D
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

not sure I have tested it on a sufficiently large dataset, but it seems to be slightly faster than the version with sumx:

top 10 supplier spend =
CALCULATE (
    SUM ( Sheet1[spendamount] );
    FILTER ( VALUES ( 'Sheet1'[supplier] ); [Supplier Ranking] <= 10 )
)

 

 

 Cheers,
Sturla

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors