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

DAX Challenge

Hi

 

I'm working on a project where I'll have to find the Number of times a Product has been upsold. For Example, If you buy a car, the sales man will pursue you to buy accesories like All Weather Mats, Roof Rail.. etc. I need to find out how many times All Weather mats are upsold with the particular Car, Like Wise for other accesories as well.

 

Sales Table:

Order#Customer#Item#Sales$
1ABCITM A100
1ABCITM B20
2BCDITM A100
2BCDITM C15
2BCDITM D20
3DEFITM X200
3DEFITM Y20
4FGHITM A100
4FGHITM C15
    

 

Upselling Part Detail

 

Master ProdutUpsellable Product
ITM AITM B
ITM AITM C
ITM XITM Y
  

 

Final Report Will Look SOmething Like this

Report Filter:  Master Product : ITM A

Total Orders: 3

 

Upsold Product# Of Orders% Upsold ( Total Order of ITM <> / Total Order)
ITM B11/3 = 33%
ITM C22/3 = 66%
   

 

Any Help is much appreciated.

Thanks

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@Anonymous Probably something like:

 

Measure = 
  VAR __Upsold = MAX('Table2'[Upsellable Product])
  VAR __MasterProducts = DISTINCT(SELECTCOLUMNS(FILTER('Table2',[Upsellable Product]=__Upsold),"Master",[Master Product]))
  VAR __Table1 = SELECTCOLUMNS(FILTER('Table1',[Item#] = __Upsold),"Order#",[Order#])
  VAR __Table2 = SELECTCOLUMNS(FILTER('Table1',[Item#] IN __MasterProducts),"Order#",[Order#])
RETURN
  COUNTROWS(INTERSECT(__Table1,__Table2)) / COUNTROWS(__Table1)
  

 

 

 


@ 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...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Anonymous Probably something like:

 

Measure = 
  VAR __Upsold = MAX('Table2'[Upsellable Product])
  VAR __MasterProducts = DISTINCT(SELECTCOLUMNS(FILTER('Table2',[Upsellable Product]=__Upsold),"Master",[Master Product]))
  VAR __Table1 = SELECTCOLUMNS(FILTER('Table1',[Item#] = __Upsold),"Order#",[Order#])
  VAR __Table2 = SELECTCOLUMNS(FILTER('Table1',[Item#] IN __MasterProducts),"Order#",[Order#])
RETURN
  COUNTROWS(INTERSECT(__Table1,__Table2)) / COUNTROWS(__Table1)
  

 

 

 


@ 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...

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