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 August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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