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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
nan_lp
Regular Visitor

DAX command to find count of distinct customer for multiple product combinations

Greetings!

 

I have a table like this,

 

User NameMobile
123iPhone
123Moto
123Moto
123OnePlus
222iPhone
333Moto
333OnePlus
444Moto
444OnePlus

 

 

I need to count distinct user across different mobile combinations like below

Mobile CombinationsDistinct Count of User Name
iPhone + Moto + OnePlus1
Moto + OnePlus2
iPhone2
Moto3
OnePlus3


Could you please help with the DAX query

 

@amitchandak 

 

2 ACCEPTED SOLUTIONS
jgeddes
Super User
Super User

Here is a DAX code you can use to create a calculated table if you want to go that way.

Calculated Table = 
var _comboTable =
SUMMARIZE(
    SUMMARIZE('Table', 'Table'[User Name], "__value", CONCATENATEX(DISTINCT('Table'), [Mobile], " + ")),
    [__value],
    "__user", DISTINCTCOUNT('Table'[User Name]),
    "_isCombo", FIND("+", [__value], 1, -1)
)
var _individualTable =
SUMMARIZE(
    'Table',
    'Table'[Mobile],
    "__user", DISTINCTCOUNT('Table'[User Name])
)
var _resultTable = 
UNION(
    SELECTCOLUMNS(FILTER(_comboTable, [_isCombo] >= 0), "Mobile Combinations", [__value], "Distinct User Count", [__user]),
    SELECTCOLUMNS(_individualTable, "Mobile Combinations", 'Table'[Mobile], "Distinct User Count", [__user])
)  
RETURN
_resultTable

'Table' would need to be replaced with your table name. 
The resulting table would like the following with the sample data you provided.

jgeddes_0-1752778102198.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This is what we typically call a market basket study i.e. "Of all those who own an iphone how many also own a Motorola".  I have solved a similar question in the attached files.  Please study these and adapt the solution there to suit your needs.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
v-agajavelly
Community Support
Community Support

Hi @nan_lp ,

Just checking in one last time haven’t seen you back in a while. As per the Microsoft Fabric Community Forum guidelines, we’ll go ahead and close this thread for now. If your issue has already been resolved, that’s great to hear.

But if you still need help down or anything else feel free to create a new post anytime. The community is always here to support you.

Regards,
Akhil.

v-agajavelly
Community Support
Community Support

Hi @nan_lp ,

Just checking in were you able to take a look at the suggestions or the PBIX file I shared? Would love to hear how it worked out for you. And if you need a hand applying it to your own model, feel free to reach out happy to help.

Regards,
Akhil.

v-agajavelly
Community Support
Community Support

Hi @nan_lp ,

Just checking in to see if you had a chance to try out the suggestions or take a look at the PBIX file shared?

Would happy to hear how it worked out for you  and feel free to shout if you need any help implementing it in your own model.

Regards,
Akhil.

 

v-agajavelly
Community Support
Community Support

Hi @nan_lp ,


Thanks for posting your interesting DAX scenario.
Just following up, the solutions shared by @ExcelMonke , @jgeddes  and @Ashish_Mathur  on above are correct and effectively address your requirement to calculate distinct user counts across different mobile combinations. The approach using calculated tables or measures along with a PBIX file provided gives a clear demonstration of how to break down and analyze distinct user participation across multiple product sets.

If you've had a chance to review and test the file or implement the logic, we’d love to hear your feedback or if you need any further clarification.

Thanks again to all the contributors for the helpful responses.

 

Regards,
Akhil

Ashish_Mathur
Super User
Super User

Hi,

This is what we typically call a market basket study i.e. "Of all those who own an iphone how many also own a Motorola".  I have solved a similar question in the attached files.  Please study these and adapt the solution there to suit your needs.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
jgeddes
Super User
Super User

Here is a DAX code you can use to create a calculated table if you want to go that way.

Calculated Table = 
var _comboTable =
SUMMARIZE(
    SUMMARIZE('Table', 'Table'[User Name], "__value", CONCATENATEX(DISTINCT('Table'), [Mobile], " + ")),
    [__value],
    "__user", DISTINCTCOUNT('Table'[User Name]),
    "_isCombo", FIND("+", [__value], 1, -1)
)
var _individualTable =
SUMMARIZE(
    'Table',
    'Table'[Mobile],
    "__user", DISTINCTCOUNT('Table'[User Name])
)
var _resultTable = 
UNION(
    SELECTCOLUMNS(FILTER(_comboTable, [_isCombo] >= 0), "Mobile Combinations", [__value], "Distinct User Count", [__user]),
    SELECTCOLUMNS(_individualTable, "Mobile Combinations", 'Table'[Mobile], "Distinct User Count", [__user])
)  
RETURN
_resultTable

'Table' would need to be replaced with your table name. 
The resulting table would like the following with the sample data you provided.

jgeddes_0-1752778102198.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





ExcelMonke
Super User
Super User

Hello,
You can consider the following first step to help get your DAX. Just remember that when pulling this into a matrix, each measure will be its own column; to get it formatted in the table you have posted, you'll need to consider something like a SWITCH function to get the formatting correct.

Your base DAX will look like something this:

Measure = 
CALCULATE(DISTINCTCOUNT(Table[User Name]), Table[Mobile] = "iPhone" && Table[Mobile] = "Moto" && Table[Mobile] = "OnePlus")




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.