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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Wybo_H
Frequent Visitor

Count rows when a given date is between two other dates

Hi,

 

I've got a date table and a table B with a date period.

Now for each date in the date table I want to count the rows from table B where the date from the date table is between the startDate and the EndDate.

17-05-2019 12-12-38 A.png

The result should be something like below.

17-05-2019 12-10-40.png

 

i've searched for a solution, but could not find it.

 

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Wybo_H 

main table

id start end
1 1/1/2019 1/1/2019
2 1/1/2019 1/2/2019
3 1/2/2019 1/5/2019
4 1/3/2019 1/5/2019
5 1/4/2019 1/6/2019
6 1/5/2019 1/6/2019
7 1/6/2019 1/7/2019
8 1/8/2019 1/9/2019
9 1/9/2019 1/9/2019

 

Calendar table contains dates above

 

Create a table

Table = FILTER(CROSSJOIN('calendar','main table'),[Date]>=[start]&&[Date]<=[end])

Then add a column in this table

count = CALCULATE(COUNT('Table'[id]),ALLEXCEPT('Table','Table'[Date]))

3.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
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

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @Wybo_H 

main table

id start end
1 1/1/2019 1/1/2019
2 1/1/2019 1/2/2019
3 1/2/2019 1/5/2019
4 1/3/2019 1/5/2019
5 1/4/2019 1/6/2019
6 1/5/2019 1/6/2019
7 1/6/2019 1/7/2019
8 1/8/2019 1/9/2019
9 1/9/2019 1/9/2019

 

Calendar table contains dates above

 

Create a table

Table = FILTER(CROSSJOIN('calendar','main table'),[Date]>=[start]&&[Date]<=[end])

Then add a column in this table

count = CALCULATE(COUNT('Table'[id]),ALLEXCEPT('Table','Table'[Date]))

3.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors