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

Customer who Bought A, what else he bought ?

Hi,

 

I have data similar to below:

 

IDAcquisition QtrPurchase QtrProductAcq Type
119Q119Q1AAt Acq
119Q118Q1BPre Acq
119Q120Q1CPost Acq
219Q219Q2CAt Acq
219Q218Q2BPre Acq
219Q220Q2A

Post Acq

 

I want to answer the following question :

 

1. What products were purchased at the time of Acquisition ? Like above, it is A & C.

2. What products were purchased prior and post acquisition ? For ex : If we select A in step 1, then I should be able to get that B product was purchased pre Acq and C was purchased post Acq.

 

I am new to power BI and DAX, it would be great help if you could provide me with appropriate code / measure or sample pbix file to perform the same.

 

Thanks,

Anshul Bhandari

4 REPLIES 4
Anonymous
Not applicable

// If you want to show the products in
// a table visual, then you have to:
// 1. Create a model table with all the products
//    and name it something like "Post-Acq Prods".
// 2. Create a model table with all the products
//    and name it something like "Pre-Acq Prods".
// 3. Keep them DISCONNECTED.
// 4. Create 2 measures (below).
// 5. Put the two tables' Product columns into
//    2 different table visuals (pre- and post-acq products).
// 6. Set visual filters on the tables using
//    the Filter pane and the 2 measures below
//    (filter by [measure] = 1).
// If you now create a slicer on the products
// from the T table (the one you showed), the two
// table visuals mentioned above will display
// the associated pre- and post-acq products.

[Is Pre-Acq Product?] =
var __acqTypeOfInterest = "pre acq"
// Let's gather all the Pre-Acq
// products that correspond to those
// "At Acq" for the same ID's and
// Acquisition Qtr. Ignore the products
// that are not "At Acq".
var __preAcqProds = 
	CALCULATETABLE(
		VALUES( T[Product] ),
		filter(
			SUMMARIZE(
				T,
				T[ID],
				T[Acquisition Qtr],
				T[Acq Type]
			),
			T[Acq Type] = "at acq"
		),
		T[Acq Type] = __acqTypeOfInterest,
		ALL( T )
	)
var __visiblePreAcqProd =
	SELECTEDVALUE( 'Pre-Acq Product'[Product] )
return
	1 * ( __visiblePreAcqProd in __preAcqProds )
	

[Is Post-Acq Product?] =
var __acqTypeOfInterest = "post acq"
// Let's gather all the Pre-Acq
// products that correspond to those
// "At Acq" for the same ID's and
// Acquisition Qtr. Ignore the products
// that are not "At Acq".
var __postAcqProds = 
	CALCULATETABLE(
		VALUES( T[Product] ),
		filter(
			SUMMARIZE(
				T,
				T[ID],
				T[Acquisition Qtr],
				T[Acq Type]
			),
			T[Acq Type] = "at acq"
		),
		T[Acq Type] = __acqTypeOfInterest,
		ALL( T )
	)
var __visiblePostAcqProd =
	SELECTEDVALUE( 'Post-Acq Product'[Product] )
return
	1 * ( __visiblePostAcqProd in __postAcqProds )

Please note that the above measures are helper measures that should only be used to filter (=1) the rows of a table visual in which products from one of the two tables I mention should be stored.

amitchandak
Super User
Super User

@Anonymous , Create measures like this and use with product or customer and product

 

At Acq= calculate(sum(Table), filter(Table,Table[Acq Type] = " At Acq"))

Pre Acq= calculate(sum(Table), filter(Table,Table[Acq Type] = "Pre Acq"))

Post Acq= calculate(sum(Table), filter(Table,Table[Acq Type] = "Post Acq"))

 

Or you can use a slicer for Acq Type

Anonymous
Not applicable

Thanks, But your solution is not giving me appropriate result. I want to create a view where if I select Product A at ACQ, then all the accounts who have purchased Product A at ACQ, and what other products were purchased in Pre Acq and Post Acq by those accounts who were Acquired by Product A at ACQ.

Greg_Deckler
Super User
Super User

@Anonymous - You could create what is called a slicer visualization on [Acq Type]. When you select things from this slicer your other visuals will filter automatically.


@ 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