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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Gutierrez
Frequent Visitor

Distinct count of Customer Name for different dates and considering filters

Hello, currently I need to get the number of unique customer sales per agent and I'm using the distinct count of customer name column considering all the filters (see below) 

 

 CALCULATE (
        DISTINCTCOUNT ( SalesDim[Customer Name] ) ,
        SalesDim[Type of Transaction] = "sale",
        SalesDim[Has Relocation Payments To This Order] = 0,
        SalesDim[POS Campaign] = BLANK (),
        SalesDim[Product ID] <> 44405,
        SalesDim[Product ID] <> 44406,
        SalesDim[Product ID] <> 44404
    )

The problem is that if a customer bought something yesterday and then today, if I filter the dates for these dates it will show up only 1 (because it's considering the same customer name) so I need to change this so it counts the distinct customer names for every day. Look an example table below
 
Product IDType of TransactionEmployee NamePOS CampaignHas Relocation Payments To This OrderDate OnlyCustomer Name
52988saleAgent A 012/15/2022Customer A
1913547saleAgent A 012/15/2022Customer B
2699468saleAgent A 012/14/2022Customer C
23566saleAgent A 012/14/2022Customer B
51570saleAgent A 012/14/2022Customer B


 

If I filter 12/14 and 12/15 for dates, the number of Unique Customer Sales should be 4 instead of 3 (Customer B appears twice on 12/14 so here it should be 1, and appears one more time on 12/15 so for this particular customer should be 2 sales between that date range). Of course, I still need to consider the filters showing above.

 

Thank you in advance.

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @Gutierrez ,

 

Please try:

Measure = 
SUMX(
    SUMMARIZE(
        SalesDim,
        SalesDim[Customer Name],
        SalesDim[Date Only],
        "distcount",
        CALCULATE (
            DISTINCTCOUNT(SalesDim[Customer Name]),
            SalesDim[Type of Transaction] = "sale"
                && SalesDim[Has Relocation Payments To This Order] = 0
                && SalesDim[POS Campaign] = BLANK ()
                && SalesDim[Product ID] <> 44405
                && SalesDim[Product ID] <> 44406
                && SalesDim[Product ID] <> 44404
        )
    ),
    [distcount]
) 

vcgaomsft_0-1672796873184.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @Gutierrez ,

 

Please try:

Measure = 
SUMX(
    SUMMARIZE(
        SalesDim,
        SalesDim[Customer Name],
        SalesDim[Date Only],
        "distcount",
        CALCULATE (
            DISTINCTCOUNT(SalesDim[Customer Name]),
            SalesDim[Type of Transaction] = "sale"
                && SalesDim[Has Relocation Payments To This Order] = 0
                && SalesDim[POS Campaign] = BLANK ()
                && SalesDim[Product ID] <> 44405
                && SalesDim[Product ID] <> 44406
                && SalesDim[Product ID] <> 44404
        )
    ),
    [distcount]
) 

vcgaomsft_0-1672796873184.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

@v-cgao-msft  Thank you! that worked for me! Appreciate it!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.