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
Anonymous
Not applicable

How do I calculate Average Daily Census on this data?

Here is a subset of the data table.  I need to be able to calculate the Average Daily Census for each program, based on the rows in this table.  I am not a programmer at all so I have no idea how to write this.  The table name is Globa28DailyCensusMA.  For the CSU program, I need to break it up into Child =<17 and adult =>18.  Of course Power Bi divides the date up into three separate columns for the visit_start_date. Any help would be appreciated.  The formula for this is: 

Avg Daily Census = Calculate(CountRows(Global28DailyCensusMA),Filter(Global28DailyCensusMA,related(visit Type[Global28DailyCensusMA])="Daily Census"))*1.0/[Number of Days]

I tried doing this but it doesn't work.

 

visit_start_dateClient IDClient AgeProgramVisit Type
7/1/2019212255CSUDaily Census
7/1/2019326260CSUDaily Census
7/1/2019489422CSUDaily Census
7/1/2019633125CSUDaily Census
7/1/2019663932DetoxDaily Census
7/1/2019694529CSUDaily Census
7/1/2019740436CrossroadsDaily Census
7/1/20191120319CSUDaily Census
7/1/20191267040CrossroadsDaily Census
7/1/20191318464DetoxDaily Census
7/1/20191402833CrossroadsDaily Census
7/1/20191867129CrossroadsDaily Census
7/1/20191903524CrossroadsDaily Census
7/1/20191909440CrossroadsDaily Census
7/1/20192077326CSUDaily Census
7/1/20192235749CSUDaily Census
7/1/20192313319CSUDaily Census
7/1/20192543626DetoxDaily Census
7/1/20192640535CrossroadsDaily Census
7/1/20192888131CSUDaily Census
7/1/20192943236DetoxDaily Census
1 ACCEPTED SOLUTION
Cmcmahan
Resident Rockstar
Resident Rockstar

Luckily, you don't need any prgramming knowledge to get this.  If you right click the table Globa28DailyCensusMA, and select the New Quick Measure option, you'll launch a helpful wizard.  You want an average by category, with that category being the date.  The base value would be a count of any column from the table.  snipa.PNG

That will create the measure for you! Mine looked like this:

 

Average Daily Census = 
AVERAGEX(
	KEEPFILTERS(VALUES('Table'[visit_start_date])),
	CALCULATE(COUNTA('Table'[Visit Type]))
)

 

 

I put that in some table visuals, filtering them by the age of the person, and came up with this from your example data. Try it with your data, and see if you come up with what you're looking for!

View solution in original post

3 REPLIES 3
dax
Community Support
Community Support

Hi rdavis61,

If possible, could you please explain this in more details("For the CSU program, I need to break it up into Child =<17 and adult =>18.  Of course Power Bi divides the date up into three separate columns for the visit_start_date. Any help would be appreciated.  ")?  In addition, you also could inform me your sample data and expecting output, then I will help  you more correctly.

 

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Cmcmahan
Resident Rockstar
Resident Rockstar

Luckily, you don't need any prgramming knowledge to get this.  If you right click the table Globa28DailyCensusMA, and select the New Quick Measure option, you'll launch a helpful wizard.  You want an average by category, with that category being the date.  The base value would be a count of any column from the table.  snipa.PNG

That will create the measure for you! Mine looked like this:

 

Average Daily Census = 
AVERAGEX(
	KEEPFILTERS(VALUES('Table'[visit_start_date])),
	CALCULATE(COUNTA('Table'[Visit Type]))
)

 

 

I put that in some table visuals, filtering them by the age of the person, and came up with this from your example data. Try it with your data, and see if you come up with what you're looking for!

Anonymous
Not applicable

This worked perfectly!  Thank you so much.  Smiley Very Happy

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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