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
Anonymous
Not applicable

Top 5 with Other Column

Hi Team,

 

Need DAX help!

 

I am looking for Top5 customer and their top unit in column.Apart from the Top 3 units which are in column I want to add all sales in Other column and then a Total Sales column. I am trying to create dax function but its not working.

 

Below is the sample data set

CustomerUnitSales
AASCM500
ABProcurment600
ACSales300
ADField209
AAMarketing948
ABProcurment305
AZMarketing382
AFServices633
AKField993
ANProcurment244
ADField362
AKMarketing750
ADProcurment250

 

 

Expected Output would be like

Top5 customer in row, Top3 unit in column(having the sales value for that unit) and "other" column (Having sales sum except the top3 value sale) and Grand total(Sum of all sales) at the end.

 

CustomerFieldMarketingProcurmentOtherGrand Total
AA 948 5001448
AB  905 905
AD571 250250821
AF   633633
AK993750  1743
      

 

Requesting you to do the needful.

 

Regards

Uphar

 

 

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Anonymous - Take a look at the Complex Filter, it has a matrix example and similar use case to what you are looking to do. Not exact, but similar. https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Complex-Selector/m-p/1116633#M534


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler 

 

I am able to fetch the top 3 unit using below DAX and top5 suppliers by using filter and TopN option. The only issue is with Other column (In which I need sum of all sales except those values which are available in top3 units). 

 

If you can help me how I can create other column in matrix. It would be a great help.

 

Top5 =
VAR __topN = 3
VAR __Unit =
RANKX (
ALLSELECTED ( Table [Sales]),
CALCULATE(
[Total Sales,
ALLEXCEPT(Table, Table[Unit] ) ),
,
DESC,
DENSE
) <= __topN

RETURN
IF( __unit, [Total_sales] )
 
How to add other column in matrix without disturbing the above DAX.
 
Regards
Uphar

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.

Top Solution Authors