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
Anonymous
Not applicable

How to approach a customers buying habits?

Hello,

I want to use i.e. traffic lights to display the status of a customer. Basically I want to show a red light if the customer have not made any order for a longer period of time, compared to his buying pattern (history). For instance if a customer have ordered things usually every week for a long time, and it is now two weeks since his last order, I want to show a red light.

 

I don't know how I should approach this, especially how to determine the customers buying pattern, and then how to compare that to the last period....

 

Anyone that have solved a similar problem?

Any help would be deeply appreciated.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

I would create a measure that calculates the AVERAGE for a customer. Perhaps like:

 

Measure 7 = 
VAR __customer = MAX('Table5'[Customer])
VAR __table = FILTER('Table5',[Customer] = __customer)
VAR __table1 = ADDCOLUMNS(__table,"__days",DATEDIFF(MAXX(FILTER(__table,[Date] < EARLIER([Date])),[Date]),[Date],DAY))
RETURN
AVERAGEX(__table1,[__days])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

I would create a measure that calculates the AVERAGE for a customer. Perhaps like:

 

Measure 7 = 
VAR __customer = MAX('Table5'[Customer])
VAR __table = FILTER('Table5',[Customer] = __customer)
VAR __table1 = ADDCOLUMNS(__table,"__days",DATEDIFF(MAXX(FILTER(__table,[Date] < EARLIER([Date])),[Date]),[Date],DAY))
RETURN
AVERAGEX(__table1,[__days])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks for your answer Greg, much appreciated. I have tried to apply your answer to my data but my knowledge about measures is very limited. Based on your example I tried the following on my specific data:

Measure 7 =
VAR __customer = MAX('Customer Order Frequency'[Sell-to customer])
VAR __table = FILTER('Customer Order Frequency';[Sell-to customer] = __customer)
VAR __table1 = ADDCOLUMNS(__table;"__days";DATEDIFF(MAXX(FILTER(__table;[Order Date] < EARLIER([Order Date]));[Order Date]);[Order Date];DAY))
RETURN
AVERAGEX(__table1;[__days])
 
And my data table looks like this for an example customer:
AverageOrderFrequency.PNG
Nothing happens though. I was expecting a new column to appear in my table?
Anonymous
Not applicable

I finally got it to work, and as I said, it was my lack of understanding of measures. Once I got a hang of that, it was pretty straight forward. Thanks Greg.

 

 

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.