Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone,
I'm trying to replicate an Excel formula in Power BI that counts the number of calls made within a 7-day window for each Contact Number. I have an Excel file with the relevant data and the formula that works correctly, but I'm struggling to get the same results in Power BI.
Contact No | Call Date |
71201 | 5/13/2024 |
2012053298 | 5/1/2024 |
2012053298 | 5/2/2024 |
2012053298 | 5/10/2024 |
2012088102 | 5/30/2024 |
2012088102 | 5/30/2024 |
2012088102 | 5/30/2024 |
2012088102 | 6/8/2024 |
2012088102 | 6/10/2024 |
2012088623 | 5/15/2024 |
2012206282 | 5/16/2024 |
2012381333 | 5/7/2024 |
2012381333 | 4/30/2024 |
2012381430 | 5/8/2024 |
2012404924 | 5/3/2024 |
2012506103 | 5/6/2024 |
2012506103 | 5/6/2024 |
2012506103 | 5/8/2024 |
The expected output I want in Power BI is:
Contact No | Call Date | Repeat Count with 7 days |
71201 | 5/13/2024 | 1 |
2012053298 | 5/1/2024 | 1 |
2012053298 | 5/2/2024 | 2 |
2012053298 | 5/10/2024 | 1 |
2012088102 | 5/30/2024 | 1 |
2012088102 | 5/30/2024 | 2 |
2012088102 | 5/30/2024 | 3 |
2012088102 | 6/8/2024 | 1 |
2012088102 | 6/10/2024 | 2 |
2012088623 | 5/15/2024 | 1 |
2012206282 | 5/16/2024 | 1 |
2012381333 | 5/7/2024 | 1 |
2012381333 | 4/30/2024 | 1 |
2012381430 | 5/8/2024 | 1 |
2012404924 | 5/3/2024 | 1 |
2012506103 | 5/6/2024 | 1 |
2012506103 | 5/6/2024 | 2 |
2012506103 | 5/8/2024 | 3 |
In Excel, I am using the following formula:
=COUNTIFS($A$1:A2,$A2,$B$1:B2,"<="&B2,$B$1:B2,">="&INT(B2)-7)
Here is the DAX formula I’m currently trying to implement:
Repeat Count With 7 days =
VAR Current No = 'Table'[Contact No]
VAR CurrentCallDate = 'Table'[Call Date]
VAR StartDate = CurrentCallDate - 7
RETURN
COUNTROWS(
FILTER(
'Table',
'Table'[ Contact No ] = CurrentANI &&
'Table'[ Call Date ] <= CurrentCallDate &&
'Table'[ Call Date ] >= StartDate
)
)
Unfortunately, the DAX formula is not returning the expected incremental counts.
Could anyone help me modify my DAX formula to achieve the desired output?
Thanks in advance!
@amitchandak @Greg_Deckler @lbendlin @Kedar_Pande @rajendraongole1 @Ritaf1983 @parry2k @audreygerred @SamWiseOwl @dharmendars007 @Omid_Motamedise @Jihwan_Kim @danextian @Ashish_Mathur @ibarrau
Solved! Go to Solution.
Hi,
PBI file attached.
Hope this helps.
Hi Ashish,
Thank you for your solution. However, the PBIX result you shared shows the incremental count for all calls based on the contact number. I’m trying to track call repeats over a 7-day window. Here’s what I need:
If you check my sample data output file, you’ll see how the 7-day period is applied.
Could you please adjust the PBIX to reflect this logic?
Thank you!
@Revanth_Reddy assuming you are adding this as a calculated column, try this:
Repeat Count With 7 days =
VAR CurrentNo = 'Table'[Contact No]
VAR CurrentCallDate = 'Table'[Call Date]
VAR StartDate = CurrentCallDate - 6
VAR RowsCount =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Call Date] ),
FILTER(
ALL ( 'Table' ),
'Table'[Contact No] = CurrentNo &&
'Table'[Call Date] <= CurrentCallDate &&
'Table'[Call Date] >= StartDate
)
)
RETURN
RowsCount
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |