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 Active Patients at beginning of each month

I have seen a few examples but I cant wrap my head around it.

 

I have two tables:  TABLE1: ACCOUNTNO, ADMITDATE, DISCHARGEDATE

TABLE2: Date, MoYear

 

I want to count the active pateints at the begining of each month which is MoYear 1/1/2022 etc..

 

SO if a pateint was admitted on or before the first of each month and discharged after that day I want toc ount that patient in the month.

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You need a measure like assume table 2 is date table and have join with ADMITDATE, if there is no join, we can remove cross filer

 

Current = CALCULATE(COUNTx(FILTER(TABLE1,TABLE1[Start Date]<=min('Date'[Date]) && (ISBLANK(TABLE1[DISCHARGEDATE]) || Employee[DISCHARGEDATE]>min('Date'[Date]))),(TABLE1[Employee Id ])),CROSSFILTER(TABLE1[ADMITDATE],'Date'[Date],None))

 

refer this blog, Max('Date'[Date]), means month end date

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

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

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , You need a measure like assume table 2 is date table and have join with ADMITDATE, if there is no join, we can remove cross filer

 

Current = CALCULATE(COUNTx(FILTER(TABLE1,TABLE1[Start Date]<=min('Date'[Date]) && (ISBLANK(TABLE1[DISCHARGEDATE]) || Employee[DISCHARGEDATE]>min('Date'[Date]))),(TABLE1[Employee Id ])),CROSSFILTER(TABLE1[ADMITDATE],'Date'[Date],None))

 

refer this blog, Max('Date'[Date]), means month end date

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

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

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.