Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
houstonh
New Member

COUNTROWS: Multiple Filters and Criteria

Hi, 

 

I am trying to figure out a complex measure and I keep getting stuck. I have added an example table below named "Orders"

 

I need to create a column to show me how many phone calls (Activity) were made within 3 days of order placement (Order Date) based on each order (Order Number). The dates between the Order Date and Activty are listed in the Days Between/Order Activity column. 

 

For example, on order "456", there are a total of 2 activities, one for the order placement and one for a phone call. I created the below calculation to show me how many total activities were completed for each order number. 

 

Total Activities = VAR __CurrentRowOrder = Orders[Order Number] return COUNTROWS(FILTER(ALL(Orders), __CurrentRowClaim = Orders[Order Number]))
 
I want a column to show how many phone calls were made for each order number. For this example, I would have a column labeled "Phone Calls" and there would be "2" for order "123" and "1" for order "456". 
 
I also need a column to show me how many phone calls were made 3 days or under after the "Order Date", essentially where Activity = "Phone Call" and Days Between Order/Activity <= 3 . For this example, order "123" would have "2" and order "456" would have "0" since the phone call was made 4 days after the order.  
 
Is something like this possible? 
 
Order NumberActivityOrder DateActivity DateDays Between Order/ActivityTotal Activities
123Order Placed1/1/20211/1/202103
456Order Placed1/2/20211/2/202102
123Phone Call1/1/20211/3/202123
123Phone Call1/1/20211/4/202133
456Phone Call1/2/20211/6/202142
1 REPLY 1
amitchandak
Super User
Super User

@houstonh , Create a new column like

countx(filter(table, [Order Number] =earlier([Order Number]) && [Activity Date] >= earlier([Order date]) && [Activity Date] <= earlier([Order date]) +3),[Order number])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.