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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Ramgopal_PBI
Frequent Visitor

Caluclate unique customer count

Hi,

A customer is purchasing products from multiple distributors. if  morethan 80%  value is purchased from one distributor then the customer is unique to that distributor. As shown in the below table1, A customer C9499 purchase products from four distributors but unique to the distributor D62. 

Table1:

DistributorCustomerTotal SalesSales%Unique customer
D19C9499$1,5003.43%0
D51C9499$2,9826.81%0
D62C9499$38,86088.79%1
D91C9499$4260.97%0
Total $43,768100%1

 

how to caluclate number of unique customers for each distributor like below table2 using DAX in PowerBI  with dynamic filter selection ?  

DistributorTotal No of CustomersNo of Unique Customers
D191314949
D511286953
D621321966
D911236918
Grand Total51573786

 

Data has following fields 

Distributor ,Region ,Country, Quarter, Product ,Customer ,Units ,Unit Price ,Total Sales

 

Thanks,

Ram

1 ACCEPTED SOLUTION
xifeng_L
Solution Sage
Solution Sage

Hi @Ramgopal_PBI ,

 

You can try below measure.

 

xifeng_L_0-1715443135987.png

 

No of Unique Customers = 
COUNTROWS(
    FILTER(
        ALLSELECTED('Distributor Sales'[Customer]),
        CALCULATE(
            DIVIDE(
                SUM('Distributor Sales'[Total Sales]),
                CALCULATE(
                    SUM('Distributor Sales'[Total Sales]),
                    ALLSELECTED('Distributor Sales'[Distributor])
                )
            )
        )>0.8
    )
)

 

Please mark this as solution and give Kudos, if this helps resolve your issue.

 

Thank you~

View solution in original post

3 REPLIES 3
xifeng_L
Solution Sage
Solution Sage

Hi @Ramgopal_PBI ,

 

You can try below measure.

 

xifeng_L_0-1715443135987.png

 

No of Unique Customers = 
COUNTROWS(
    FILTER(
        ALLSELECTED('Distributor Sales'[Customer]),
        CALCULATE(
            DIVIDE(
                SUM('Distributor Sales'[Total Sales]),
                CALCULATE(
                    SUM('Distributor Sales'[Total Sales]),
                    ALLSELECTED('Distributor Sales'[Distributor])
                )
            )
        )>0.8
    )
)

 

Please mark this as solution and give Kudos, if this helps resolve your issue.

 

Thank you~

v-yifanw-msft
Community Support
Community Support

Hi @Ramgopal_PBI ,

Based on the information you provided, can you explain how your "unique customers" was calculated to get it. If you do not mind could you also provide some detailed data (without sensitive information), providing specific data and clearly expressing the results you want can help us better understand your problem.

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Ada Wang,

 

We have 100 distributors and 10000 customers in the sample data. A customuer bought products from the multiple distributors , if the customer bought mostly (above 80%) from one distributor then the customer is unique. Let say If the customer 'C' bought total 100$ from three distributors  D1,D2 and D3 10$,7$ and 83$ respectively.Here the customer 'C' is bought morethan 80% value from the distributor D3 , hence the customer 'C' is unique. 

 

Sales% bought from D1 = 10/(10+7+83)

Sales% bought from D2 = 7/(10+7+83)

Sales% bought from D3 = 83/(10+7+83)

Now need to caluclate the number of unique customers by Distributor.

 

The required output is  

DistributorTotal No of CustomersNo of Unique Customers
D191314949
D511286953
D621321966
D911236918
Grand Total51573786

 

Sample Data file : 

https://docs.google.com/spreadsheets/d/1jJnXYD5bA6tMzsdQctbiosBFfjVhte-r/edit?usp=drive_link&ouid=11...

 

PBIX File: 

https://drive.google.com/file/d/11BnGBM1aFVas4ewdaK8caJNS6_WoiETg/view?usp=drive_link

 

This might be achived through nested aggregations.

 

Step 1 : Distributor , Customer, Sales%

Step2: Distributor,Customer count where Sales% >80%

 

Thank you,

Ram

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Top Kudoed Authors