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
Syndicate_Admin
Administrator
Administrator

Count customers between dates if they haven't purchased before

Good morning, everyone,

Thanks in advance for the help. I have a question for a long time and I do not know how to solve it. I work with a table that I simulate below.

Frangranada_0-1669537625603.png

I want to know how to count customers for dates that I mark on the calendar, as long as they have not bought before. Ahem: If I mark in the calendar the dates from 21/11 to 24/11, the number of different clients is 5. Now, if I march alone on 11/23, then it's 2. What I want to achieve is that if I mark the day 24/11 instead of counting 5, only count me 2 (customer 3 and 5), since customers 1, 2 and 4 have bought on previous dates.

I hope I haven't messed up too much.

Thank you again for your help.

Greetings

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

Hi @Syndicate_Admin ,

According to your description, here's my solution. Create a calculated column.

Count =
SUMX (
    FILTER (
        'Table',
        'Table'[Clients] = EARLIER ( 'Table'[Clients] )
            && 'Table'[Date of purchase] = EARLIER ( 'Table'[Date of purchase] )
    ),
    IF (
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[Clients] = EARLIER ( 'Table'[Clients] )
                    && 'Table'[Date of purchase] < EARLIER ( 'Table'[Date of purchase] )
            )
        ) + 0 = 0,
        1
    )
)

Put Date and the new column in a visual, get the correct result:

vkalyjmsft_0-1669618281784.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

3 REPLIES 3
v-yanjiang-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

According to your description, here's my solution. Create a calculated column.

Count =
SUMX (
    FILTER (
        'Table',
        'Table'[Clients] = EARLIER ( 'Table'[Clients] )
            && 'Table'[Date of purchase] = EARLIER ( 'Table'[Date of purchase] )
    ),
    IF (
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[Clients] = EARLIER ( 'Table'[Clients] )
                    && 'Table'[Date of purchase] < EARLIER ( 'Table'[Date of purchase] )
            )
        ) + 0 = 0,
        1
    )
)

Put Date and the new column in a visual, get the correct result:

vkalyjmsft_0-1669618281784.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

vanessafvg
Super User
Super User

please provide the sample data in text form.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




The example table.

ClientsDate of purchaseUnits
Client 121/11/202235
Client 222/11/202248
Client 123/11/202212
Client 324/11/202224
Client 423/11/202256
Client 224/11/202224
Client 124/11/202236
Client 424/11/202212
Clinete 524/11/202218

The idea is to know for any day, the number of unique customers who have not bought since 21/11

Thank you

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.