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
mficco
Frequent Visitor

Counting occurrences between two dates and filtering by categories

Hi! I have been trying to make this measure work properly but i have not suceeded yet.

Basically I have 3 tables in my model:

- DATE

- EVENTS

- DATA

 

The EVENTS table looks something like this:

Person IDClassStart date1End date1Start date2End date2…..
1OK1/3/20205/3/20206/3/202028/3/2020 
2OK5/4/202010/4/202011/4/202023/4/2020 
3NO6/4/2020    

 

And my DATA table like this:

Person IDCityDepartmentArea
1aazzrr
2bbxxss
3ccyytt

 

I have wrote this measure to count the occurrences between start date and end date and it works succesfully.

Occ.1 = CALCULATE(DISTINCTCOUNT(EVENTS[PersonID]);FILTER(ALL(EVENTS);(EVENTS[Start Date1]<=MAX(DATE[Date]) && EVENTS[End Date1]>=MAX(DATE[Date])));EVENTS[Class]="OK")

 

But when I try to filter the visual by City for example, I just get the days in which the event starts and not all the occurrances between start and end date. 

 

 

Any idea or help is welcome.

Thanks!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@mficco - It sounds like you want Open Tickets but hard to say. https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364#M147



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@mficco - It sounds like you want Open Tickets but hard to say. https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364#M147



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.