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

Find out which buying client bought previous month

Hi all!

 

I have a table containing all clients who ever placed an order. The coulmns are:

Date, Client ID, Order ID

 

What I want to find out is which clients who placed an order in current month, also placed an order in previous month. Or more precisely, Percent of buying customers in current month who bought last month. Does anyone have a suggestion on how to do this?

 

Thank you in advance!

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@ny326n

 

For your requirement, you can create a full calendar table, then build relationship to your table on Date column. Then you can add a "Tag" column to tag if an users has order in previous month:

 

IsActive =
IF (
    CALCULATE (
        COUNTROWS ( Table ),
        PREVIOUSMONTH ( Table[Date] ),
        ALLEXCEPT ( Table, Table[ClientID] )
    )
        > 0,
    1,
    0
)

Capture.PNG

 

 

Then you can easily calculate active users percentage with above column:

 

Active User Pct=
CALCULATE (
    DISTINCTCOUNT ( Table[ClientID] ),
    ALLEXCEPT ( Table, Table[Month] ),
    FILTER ( Table, Table[IsActive] = 1 )
)
    / CALCULATE (
        DISTINCTCOUNT ( Table[ClientID] ),
        ALLEXCEPT ( Table, Table[Month] )
    )

Regards,

 

View solution in original post

2 REPLIES 2
v-sihou-msft
Employee
Employee

@ny326n

 

For your requirement, you can create a full calendar table, then build relationship to your table on Date column. Then you can add a "Tag" column to tag if an users has order in previous month:

 

IsActive =
IF (
    CALCULATE (
        COUNTROWS ( Table ),
        PREVIOUSMONTH ( Table[Date] ),
        ALLEXCEPT ( Table, Table[ClientID] )
    )
        > 0,
    1,
    0
)

Capture.PNG

 

 

Then you can easily calculate active users percentage with above column:

 

Active User Pct=
CALCULATE (
    DISTINCTCOUNT ( Table[ClientID] ),
    ALLEXCEPT ( Table, Table[Month] ),
    FILTER ( Table, Table[IsActive] = 1 )
)
    / CALCULATE (
        DISTINCTCOUNT ( Table[ClientID] ),
        ALLEXCEPT ( Table, Table[Month] )
    )

Regards,

 

Thank you for this Simon!

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.