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
Mubar22
Frequent Visitor

Customer with only One Purchase Across a Period

Hello Power BI Dev,,

I have sales table and I want to count the unique customers that only purchase once across a period. i.e let's say the period is between 2023-2024 so the customer only purchase once irrespective of the month.

 

I have this measure written, but it's not giving the right output.

 

OneTimeCustomers = 
VAR MaxDate = MAX('Date Table'[Date])
RETURN
    COUNTROWS(
            FILTER(
                ADDCOLUMNS(
                    SUMMARIZE('Sales', 'Sales'[companyID]),
                    "Total Orders", DISTINCTCOUNT('Sales'[invoiceID])
                ),
                [Total Orders] = 1 && MIN('Sales'[OrderDate]) < MaxDate
            ))

 

Attached is a screenshot of what I want to achieve using the filter pane on the visual.

Mubar22_0-1714140099567.png

Kindly help out.
Thanks

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @Mubar22 ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
MFelix
Super User
Super User

Hi @Mubar22 ,

 

You are not removing the filter context of the dates to get the full time period so when you get the max and minimum date you get for that specific month and not for the full period of sales try the following code:

 

OneTimeCustomers = 
VAR MaxDate = MAX('Date Table'[Date])
RETURN
    COUNTROWS(
            FILTER(
               CALCULATETABLE( ADDCOLUMNS(
                    SUMMARIZE('Sales', 'Sales'[companyID]),
                    "Total Orders", DISTINCTCOUNT('Sales'[invoiceID])
                ), ALLSELECTED(Date Table)),
                [Total Orders] = 1 && MIN('Sales'[OrderDate]) < MaxDate
            ))

Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

This doesn't work, it's returning blank.

Hi @Mubar22

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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.