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
mboschbe
Helper I
Helper I

Identify first time customer purchased one SKU

Hello!

 

I would like to identify when a customer had purchased a sku for the first time and when had purchased for the second time (as a replacement). 

 

My table is as following:

ITEM CODEDATEQTYORDER IDCUSTOMER IDTYPE
A01/01/2019201C061st
B01/01/2019101C06

1st

C01/01/2019101C061st
A01/05/20191075C06REPLACEMENT
D01/05/20191075C061st

 

Is it possible to do it? Can anybody help me out? SO far I've been only able to identify first sales order of a customer.

 

Thanks!

 

6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi @mboschbe 

It works with amitchandak's forluma

Capture3.JPG

Column =
COUNTX (
    FILTER (
        'Table',
        'Table'[ITEM CODE]
            = EARLIER ( 'Table'[ITEM CODE] )
            && 'Table'[CUSTOMER ID]
                = EARLIER ( 'Table'[CUSTOMER ID] )
            && 'Table'[DATE]
                <= EARLIER ( 'Table'[DATE] )
    ),
    [ORDER ID]
)

Column 2 = IF([Column]=1,"1st","replacement")

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hello!

 

I have  little problem when using this formula, is not about the formula is about how data is set.

 

A customer places two orders same day to buy for the first time one SKU. Customer orders two units,same SKU different orders but same date.

My date data for both orders is showed as 13/01/2020 (00:00)

 

When applying formula, it gives me that both units are replacement so in this case for this customer I don't have a 1st purchase.

 

Do you think it will be possible to update formula in order to identify one of the orders as 1st? or both orders as 1st?

 

Many thanks!

Hi @mboschbe 

Column = 
CALCULATE(DISTINCTCOUNT('Table'[DATE]),
    FILTER (
        'Table',
        'Table'[ITEM CODE]
            = EARLIER ( 'Table'[ITEM CODE] )
            && 'Table'[CUSTOMER ID]
                = EARLIER ( 'Table'[CUSTOMER ID] )
            && 'Table'[DATE]
                <= EARLIER ( 'Table'[DATE] )
    ))

Column 2 = IF([Column]=1,"1st","replacement")

Capture10.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello!

 

Thanks for your reply.

 

I tried applying new formula but power bi says processing but it never finishes calculating (two hours calculating already).

 

Is it may be because the same data base contains many different customers? Or it can be only because data base is big and it just needs more time? 

 

Many thanks!

Hey!

 

Many thanks for your help and quick response. All works 🙂

 

amitchandak
Super User
Super User

You can create a new column of count and use that to find new and replacement

 

count of sales = countx(filter(table, table[ITEM CODE] =earlier(table[ITEM CODE])
							&& table[CUSTOMER ID] =earlier(table[CUSTOMER ID])
							&& table[DATE] <=earlier(table[DATE])),table[ORDER ID])

 

Appreciate your Kudos.

 

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.