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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
kalkhudary
Helper IV
Helper IV

Average Spend Amount based on the top 5 spenders and based on overall department all employees spend

Hi All, 

I want to generate a matrix table the presents the below. I have a filter for date and business unit in my dashboard. If I click on Technolgy Department, I see the below names since I added the topN filter to show the top 5 spenders based on spend amount. 

 

Employee NameSpend AmountAverage Spend AmountOverall Average Spend Amount
Zak1000500300
Max20001000200
Bernard5500600150
Leo4005020
Sarah600250100
Total95003000150

 

I am trying to dax 2 measures, one that look at the average of the Spend Amount based on the top 5 spenders and one that looks at the overall average spend amount based on All employees in the Technology Department.

 

Would appreciate any help in daxing the concept above.

1 ACCEPTED SOLUTION

@kalkhudary Use ALLSELECTED instead of ALL



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
kalkhudary
Helper IV
Helper IV

@Greg_Deckler Can you try based on the table above by instering employee names and spend amounts with 2 different business units and check the outcome. I can't insert a BI file here.

@kalkhudary See PBIX below signature.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler That sounds to work but what if I need to filter to a particular business unit and see its top 2 average, how will I embed it in the dax to read it this way instead of looking at all table. What can we change in the first var to allow it to calculate based on selected business unit 

 

   VAR __Table0 = ALL('Table')
    VAR __Table1 = TOPN( 2, __Table0, [Spend Amount] )
    VAR __Table2 = SUMMARIZE( __Table1, [Employee Name], "__Value", SUM( 'Table'[Spend Amount] ) )
    VAR __Result = AVERAGEX( __Table2, [__Value] )
RETURN
   __Result

@kalkhudary Use ALLSELECTED instead of ALL



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

@kalkhudary Not sure since no sample data provided but maybe:

Average Spend Amount = 
  AVERAGEX ( DISTINCT( 'Table'[Employee Name] ), SUM( 'Table'[Spend Amount] )

Average Spend Amount Overall = 
  AVERAGEX ( ALL( 'Table'[Employee Name] ), SUM( 'Table'[Spend Amount] )

Assumes that these are used in a visual with a Top-N filter.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler It is providing repititive values for both measures. Not sure what we may be missing. See snippet of the table and applied filters.

 

Average.PNG

@kalkhudary Tough to say. Really need sample data as text to recreate.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors