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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Count number of top 10 products that each customer have bought

I'm trying to post again, since last time gave no reply. 

Hi all 

I want to know how many of the top 10 products (eg. 4 out of 10) that each customer have bought (E.g. if a customer bought 10.000 units of one top 10 product the meassure should return 1) 

I have calculated how many products (Modules) each customer have using the following meassure: 

CALCULATE(DISTINCTCOUNT('Module impressions (API)'[Module name]); GROUPBY('Module impressions (API)';'Module impressions (API)'[Customer ID]))
 
I have also ranked the products by number of times they have been sold (Impressions) using the following meassure: 
RANKX(ALLSELECTED('Modules All'[Module name]);CALCULATE(SUM('Module impressions (API)'[Impressions])))
 
I now want to calculate how many of the top 10 ranked products that each customer have. 

Currently my data looks like this: 

Customer database (Customers) 
Customer nameInfo 1 Info 2Info k
Customer A
Customer B
Customer i

 

Module database/ Product database (Modules All) 

Module nameInfo 1 Info 2Info k
Module A
Module B
Module j

Sales database / Impressions database (Module impressions (API)

Customer nameModule nameImpressionsDateInfo k
Customer AMudule A63901-01-2020
Customer AMudule A21602-01-2020
Customer BModule B94501-01-2020
Customer BModule B10702-01-2020
Custuomer iModule jXX

 
And my visuals look like this 

Module nameModule rankImpressions
Module A183245575
Module B274723660
Module jRank h5371075


Customer name# Modules
Customer A35
Customer B29
Custuomer i1

I would like to add the # of top 10 modules/products to the table above in a new collumn. 

 

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

Perhaps something along the lines of:

 

Measure = 
  VAR __Customer = MAX(Customers[Customer name])
  VAR __Top10 = SELECTCOLUMNS(FILTER('Module impressions',[Module Rank]<=10),"__Module",[Module name])
  VAR __Modules = SELECTCOLUMNS(FILTER('Module impressions',[Customer name]=__Customer,"__Module",[Module name])
RETURN
  10 - 
  COUNTROWS(
    EXCEPT(
      __Top10,
      __Modules
    )
  )

 



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

Hi @Greg_Deckler 

I tried putting in your dax code in a new meassure, but it cannot find the "[Customer name]" or the "[Module name]" in the variable ___modules, It seems that it can only find measures instead of tables or collumns. 

Your table names are probably diffferent than what I used in my example code?



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

I tried using other table names, but i'm not even allowed to pick table names, only meassures. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.