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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
DominicK
Helper I
Helper I

Count Values Between Two Dates

I have created the below column chart which is correct however the DAX code I used to create the columns is far too long.

 

I want to show the values of Asset Class between Sep 19 to Feb 20 and the same between March 20 to Sep 20

What is the cleanest formulat to calculate values between two dates, my current formula involved selecting each individual day (example below)

 

DominicK_1-1599210291921.png

 

 

 

DominicK_0-1599210107613.png

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@DominicK, you can try as

calculate(countA(Sheet1[Asset Class]), filter(Sheet1,Sheet1[Date] > date(2019,09,01) && Sheet1[Date] < date(2020,02,29)))

You can try this with the date table

calculate(countA(Sheet1[Asset Class]), DATESBETWEEN(DAte[Data], date(2019,09,01), date(2020,02,29)))

You can use date segmentation and this will work -countA(Sheet1[Asset Class])

To get the best out of the time intelligence function. Make sure that you have a date calendar and that it has been marked as the date in the model view. Also, join her with the date column of your events. Recommended:
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my Time Intelligence webinar can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


We appreciate your congratulations.

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@DominicK, you can try as

calculate(countA(Sheet1[Asset Class]), filter(Sheet1,Sheet1[Date] > date(2019,09,01) && Sheet1[Date] < date(2020,02,29)))

You can try this with the date table

calculate(countA(Sheet1[Asset Class]), DATESBETWEEN(DAte[Data], date(2019,09,01), date(2020,02,29)))

You can use date segmentation and this will work -countA(Sheet1[Asset Class])

To get the best out of the time intelligence function. Make sure that you have a date calendar and that it has been marked as the date in the model view. Also, join her with the date column of your events. Recommended:
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my Time Intelligence webinar can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


We appreciate your congratulations.

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

@amitchandak 

Thank You!

 

I will be looking at automating this report.

 

Do you have any advice on how to create a measure that shows a rolling 6 months?

 

Next quarter I will want to run this again but the dates will be different( December 2019 - June 2020 and July 2020 - December 2020)

 

 

Thanks!

 

 

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.