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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

Monthly Inmate Count From Booking and Release date

Hello all,

 

I have the booking and release date for inmates in a Jail. I would like to have the count of inmates in jail per month. I have tried the following DAX code: 

 

InmateCount =
VAR selectedDate = Max ('Date'[Date])
RETURN
SUMX(vwBookingSearch,
VAR InmateStartDate = [BookingDate1]
VAR InmateEndDate = [ReleaseDate1]
RETURN IF (InmateStartDate<= selectedDate &&OR (InmateEndDate>selectedDate, InmateEndDate=BLANK()),1,0))
 
However this returns a number much smaller than the actuall answer. I do not have my vwBookingSEarch table related to the date table. I am wondering if this might not work because I have multiple years of data and the Max('Date'[Date]) function might be messing up the output. Any ideas would help regardless of using this code.
 
Thank you.
5 REPLIES 5
alivenjess
New Member

Hello there,

It sounds like you're working on a data analysis project involving inmate counts from booking and release dates, and you're encountering some discrepancies in your results. It's possible that the issue lies in the relationship between your 'Date' table and the 'vwBookingSearch' table, especially considering multiple years of data. The Max('Date'[Date]) function might indeed be affecting the output, so exploring alternative approaches or refining your DAX code could be beneficial. Additionally, ensuring a proper relationship between your tables could help resolve the discrepancy. Having accurate data is crucial, just like having a reliable mugshot to identify individuals accurately. 

amitchandak
Super User
Super User

@Anonymous , seems similar to HR problem. Refer to the blog or file attached

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you. The HR problem is similar but also gives very low answers. I know from the data source that the inmates get booked into that the inmate count is nearly 70 every month. Here Is what I get with both of these attempts:

employee.PNG

This is identical for what I tried the first time and the second. My data looks the same as the HR example.

Anonymous
Not applicable

I can tell it has something to do with the date relationship because if I break it down by year this is what I get a smaller number then all the months combined for 2022.

yearly.PNG

 

Anonymous
Not applicable

I fixed this by duplicating the table and deleting all other relationships from it.

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors