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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
alir22456
Helper I
Helper I

Power Query

I have a large historical dataset of customers and the services (Plans) they had bought from my company. I am working on a Cross-Selling analysis project.

alir22456_3-1720672934544.png

 

Based on this data, I want to see the names of the customers who (for example) bought Plan 4 and Plan 10.

alir22456_4-1720672948204.png

Note: I want to see only the customers who bought both of these plans. Not individually. 

1 ACCEPTED SOLUTION
fahadqadir3
Super User
Super User

@alir22456 Review the attached screenshot and DAX code to get the desired results.

fahadqadir3_0-1720675286351.png

 

Cohort = 
VAR __tmpTable1 =
GENERATE(
DISTINCT('Table'[Customers]),
EXCEPT(
DISTINCT('Table'[Services]),
CALCULATETABLE(DISTINCT('Table'[Services]))
)
)
VAR __tmpTable2 = SUMMARIZE(__tmpTable1, 'Table'[Customers])
VAR __tmpTable3 = EXCEPT(DISTINCT('Table'[Customers]), __tmpTable2)
VAR __Result = CONCATENATEX(__tmpTable3, [Customers], ",", [Customers])
RETURN
__Result
SelectedPlans = 
VAR SelectedPlansTable = VALUES('Table'[Services])
RETURN
IF(
ISBLANK(CONCATENATEX(SelectedPlansTable, 'Table'[Services], " and ")),
"No Plan Selected",
CONCATENATEX(SelectedPlansTable, 'Table'[Services], " and ")
)

Hope it works.

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!! 

View solution in original post

3 REPLIES 3
alir22456
Helper I
Helper I

Thanks @fahadqadir3 for your solution,

Can you please tell if there is a way to see the list of customers who bought Plan 10 minus the customers who bought Plan 10 and Plan 4?

 

Targeted Customers = Plan 10 Customers - (Plan 10 Customers and Plan 4 Customers)

fahadqadir3
Super User
Super User

@alir22456 Review the attached screenshot and DAX code to get the desired results.

fahadqadir3_0-1720675286351.png

 

Cohort = 
VAR __tmpTable1 =
GENERATE(
DISTINCT('Table'[Customers]),
EXCEPT(
DISTINCT('Table'[Services]),
CALCULATETABLE(DISTINCT('Table'[Services]))
)
)
VAR __tmpTable2 = SUMMARIZE(__tmpTable1, 'Table'[Customers])
VAR __tmpTable3 = EXCEPT(DISTINCT('Table'[Customers]), __tmpTable2)
VAR __Result = CONCATENATEX(__tmpTable3, [Customers], ",", [Customers])
RETURN
__Result
SelectedPlans = 
VAR SelectedPlansTable = VALUES('Table'[Services])
RETURN
IF(
ISBLANK(CONCATENATEX(SelectedPlansTable, 'Table'[Services], " and ")),
"No Plan Selected",
CONCATENATEX(SelectedPlansTable, 'Table'[Services], " and ")
)

Hope it works.

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!! 

Hi @fahadqadir3 

Thank you for the above solution. Can you please tell if each customer name in the visualization can be displayed in separate rows instead of comma separated. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.