Forum Discussion
TOP N customers per week
Hi alefebvre -Hope you already create a new calculated column to extract the week number from your date column as below:
calculated column:
WeekNumber = WEEKNUM('Emails'[Date], 2) -- 2 means the week starts on Monday
create measure to calculate the total emails
EmailsPerWeek =
CALCULATE(
COUNT('Emails'[EmailID]),
ALLEXCEPT('Emails', 'Emails'[Customer], 'Emails'[WeekNumber])
)
Create another measure to rank customers based on the number of emails
CustomerRankPerWeek =
RANKX(
ALL('Emails'[Customer]),
[EmailsPerWeek],
,
DESC,
DENSE
)
create anothe measure to filter
Top5CustomersEmailsPerWeek =
IF(
[CustomerRankPerWeek] <= 5,
[EmailsPerWeek],
BLANK()
)
Hope it works ,please check
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Hello,
Thank you for your solution, I will try to adapt my project with your solution. I will still contextualize my project just in case.
As you can see in the image to make my TOP N, I use the following 3 tables:
- Messages: Email table
- Date de reception: Calendar table
- Contacts: Table of sender contacts
As mentioned in my previous post, I manage to get the top 5 per week over the last 30 days but over the entire 30 days (see the image below), which does not correspond to my goal which is to make the top 5 per week over the last 30 days.
Again, thank you for your feedback.