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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Count rows based on Two dates

Hi Team,

 

I have a data of Start date and End date and product id. I want to calcuate count of product Id based condition on start date and end date.

 

Example- I want to calcuated count

select count (*) from tabel

where startdate >= '1-8-2019' and end date <= '31-8-2019'

 So want to calculate count for every month Jan to Dec based on Start date and end date.

Could you please give some idea about this.

 

Thanks

3 REPLIES 3
kentyler
Solution Sage
Solution Sage

Take a look at the function CALCULATE() it allows you to add more than one filter expression
VAR row_count = CALCULATE(COUNTROWS(table),startdate >= '1-8-2019' ,end date <= '31-8-2019')
this example assumes that there are not external filters on your table, if there are you might want to include a filter expression using ALL()---> ALL(table)





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Anonymous
Not applicable

Hi,

 

Thanks for solution.

 

But I have to do it for all months. I am having data more than 3 years so i want to visuals year wise start date and end date values in X axis.

 

Please suggest.

 

 

 

Anonymous
Not applicable

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.