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
Chanleakna123
Post Prodigy
Post Prodigy

Re-Purchased Customer By N Day

1.PNG

 

hi , I have 9 PUrchased Customers , by Filter MEP , and i have total Customers are 94 for MEP , 

I have Delivery Date of customer who purchase the order by customer code and customer name  with the QTY as well as the 2nd table, 

My purpose is to see , who is the Re-Purchased Customer By N Days ? 
For example : Customer Lach Sophea purchased on Dec 4 and Dec 5 , he's a Re-Purchased Customer . because he purchased twice during 2 days. 
Let say , i use Parameter for N Day ( 7 Days )  , During these 7 Days , Is Lach Sopheak Still Purchase any day for twice or more than this ? if it's more than 1 time purchase during these 7 days , He's A Re-Purchased Customer , But during these 7 days if he purchases only 1 time , he's not Re-PUrchased Customers. 

 

My purpose is to see how many Re-Purchased Customers by N Days

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Chanleakna123,

 

Please refer to below measures:

pur datediff =
VAR currentpurchase =
    SELECTEDVALUE ( Tab_2[Delivery Date] )
VAR nextpurchase =
    CALCULATE (
        MIN ( Tab_2[Delivery Date] ),
        FILTER (
            ALLEXCEPT ( Tab_2, Tab_2[Customer Code] ),
            Tab_2[Delivery Date] > currentpurchase
        )
    )
RETURN
    DATEDIFF ( currentpurchase, nextpurchase, DAY )

min datediff =
MINX (
    FILTER (
        ALLSELECTED ( Tab_2 ),
        Tab_2[Customer Code] = SELECTEDVALUE ( Tab_2[Customer Code] )
    ),
    [pur datediff]
)

is in NDay =
IF (
    [pur datediff] <> BLANK (),
    IF ( [min datediff] <= NDay[NDay Value], "Y", "N" ),
    BLANK ()
)

count re-purchased =
CALCULATE (
    DISTINCTCOUNT ( Tab_2[Customer Code] ),
    FILTER ( ALLSELECTED ( Tab_2 ), Tab_2[is in NDay] = "Y" )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @Chanleakna123,

 

Please refer to below measures:

pur datediff =
VAR currentpurchase =
    SELECTEDVALUE ( Tab_2[Delivery Date] )
VAR nextpurchase =
    CALCULATE (
        MIN ( Tab_2[Delivery Date] ),
        FILTER (
            ALLEXCEPT ( Tab_2, Tab_2[Customer Code] ),
            Tab_2[Delivery Date] > currentpurchase
        )
    )
RETURN
    DATEDIFF ( currentpurchase, nextpurchase, DAY )

min datediff =
MINX (
    FILTER (
        ALLSELECTED ( Tab_2 ),
        Tab_2[Customer Code] = SELECTEDVALUE ( Tab_2[Customer Code] )
    ),
    [pur datediff]
)

is in NDay =
IF (
    [pur datediff] <> BLANK (),
    IF ( [min datediff] <= NDay[NDay Value], "Y", "N" ),
    BLANK ()
)

count re-purchased =
CALCULATE (
    DISTINCTCOUNT ( Tab_2[Customer Code] ),
    FILTER ( ALLSELECTED ( Tab_2 ), Tab_2[is in NDay] = "Y" )
)

1.PNG

 

Best regards,

Yuliana Gu

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

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.