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.
HI ,
I have a table with supplier name , their category and their spend . I need to create a visual table which will show me the fragmentation of supplier spend across these categories . The output I am looking for in the visual is something like this :
Category | Top 3 Suppliers contribution to overall category spend | Top 5 Suppliers contribution to overall category spend | Top 10 Suppliers contribution to overall category spend |
A | 75% | 85% | 100% |
B | 55% | 65% | 70% |
C | 20% | 25% | 30% |
Any ideas on how to go about this ?
Solved! Go to Solution.
Hi @manish2k
Try creating a calculated table that summarises the data using this code
Summary Table = SUMMARIZE( 'Table1', Table1[Supplier Name], 'Table1'[Category] , "Total Spend",SUM('Table1'[Spend]) )
Then add the following calculated column to this newly created table
Supplier Category Rank = CALCULATE( COUNTROWS('Summary Table'), FILTER('Summary Table', 'Summary Table'[Category] = EARLIER('Summary Table'[Category]) && 'Summary Table'[Total Spend] >= EARLIER('Summary Table'[Total Spend] ) ) )+0
Finally create the following measure
Top 3 Suppliers contribution to overall cat spend =
VAR TopNValue = 3
VAR Top3Spend = CALCULATE(
SUM('Summary Table'[Total Spend]),
FILTER(
ALLEXCEPT('Summary Table','Summary Table'[Category]),
'Summary Table'[Supplier Category Rank]<=TopNValue)
)
VAR TotalSpend = CALCULATE(SUM('Summary Table'[Total Spend]),ALLEXCEPT('Summary Table','Summary Table'[Category]))
RETURN DIVIDE(Top3Spend,TotalSpend)
and format the measure to be a percentage. I think this might be close 🙂
If it's close, just clone the final measure 2 times for the other TopN values
Hi @manish2k
Try creating a calculated table that summarises the data using this code
Summary Table = SUMMARIZE( 'Table1', Table1[Supplier Name], 'Table1'[Category] , "Total Spend",SUM('Table1'[Spend]) )
Then add the following calculated column to this newly created table
Supplier Category Rank = CALCULATE( COUNTROWS('Summary Table'), FILTER('Summary Table', 'Summary Table'[Category] = EARLIER('Summary Table'[Category]) && 'Summary Table'[Total Spend] >= EARLIER('Summary Table'[Total Spend] ) ) )+0
Finally create the following measure
Top 3 Suppliers contribution to overall cat spend =
VAR TopNValue = 3
VAR Top3Spend = CALCULATE(
SUM('Summary Table'[Total Spend]),
FILTER(
ALLEXCEPT('Summary Table','Summary Table'[Category]),
'Summary Table'[Supplier Category Rank]<=TopNValue)
)
VAR TotalSpend = CALCULATE(SUM('Summary Table'[Total Spend]),ALLEXCEPT('Summary Table','Summary Table'[Category]))
RETURN DIVIDE(Top3Spend,TotalSpend)
and format the measure to be a percentage. I think this might be close 🙂
If it's close, just clone the final measure 2 times for the other TopN values
@Phil_Seamark I have one change to ask , what if the main summary table gets one more filer . Let say a department . How will i be able to incorporate it into the below code?
Awesome ! This worked ! Thanks a million !
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
89 | |
68 | |
61 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |