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
saferguson
Regular Visitor

Filtering grouped data

Hi,

 

I'm trying to figure out repeat customers (where repeat customers are defined as customers making multiple transactions on different dates (i.e. so if a customer makes 3 transactions in one day but no other transactions they count as a new customer). 

 

Example data: 

Customer IDTransaction dateValue
130/12/201711
131/12/201736
201/01/201854
202/01/201834
303/01/201810
303/01/201822

 

 

So far I've duplicated the columns, removed everything except date & customer ID and grouped the data on customer ID so the data looks like this:

Customer IDUnique transaction dates
12
22
31

 

Using % repeats = calculate(count([customer ID]), unique transcation dates >1)/distinctcount([customer ID]) 

gives a perecent of repeat customers of 66% which is good

 

However, if I want to apply a filter in a report to look at transactions made in 2018, my measure doesn't change as the grouping removes the date column. In this case I want my grouped data to look like this:

Customer IDUnique transaction dates (2018)
22
31

 

Giving a % repeats of 50%.

 

Similarly if Customer 1 had made one transaction in 2018 and one in 2017 I'd still like them to appear as a repeat customer, as they've made a transaction in the year filtered for & have made bookings previously. 

 

Hope this makes sense, thank you in advance!

 

Sarah

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @saferguson,

 

Please try below measures:

Unique transaction dates =
CALCULATE (
    DISTINCTCOUNT ( 'Customer Transaction'[Transaction date] ),
    ALLEXCEPT ( 'Customer Transaction', 'Customer Transaction'[Customer ID] )
)

Using % repeats =
CALCULATE (
    DISTINCTCOUNT ( 'Customer Transaction'[Customer ID] ),
    FILTER ( 'Customer Transaction', [Unique transaction dates] > 1 )
)
    / DISTINCTCOUNT ( 'Customer Transaction'[Customer ID] )

1.PNG2.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

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @saferguson,

 

Please try below measures:

Unique transaction dates =
CALCULATE (
    DISTINCTCOUNT ( 'Customer Transaction'[Transaction date] ),
    ALLEXCEPT ( 'Customer Transaction', 'Customer Transaction'[Customer ID] )
)

Using % repeats =
CALCULATE (
    DISTINCTCOUNT ( 'Customer Transaction'[Customer ID] ),
    FILTER ( 'Customer Transaction', [Unique transaction dates] > 1 )
)
    / DISTINCTCOUNT ( 'Customer Transaction'[Customer ID] )

1.PNG2.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.

Brilliant, that works. Thank you! Could you please explain what exactly you've done just so I understand fully?

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.