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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DM_BI
Helper III
Helper III

Days between 2 dates in same table and by month name

Hello,

 

I have a table that has three columns, one is the person ID, one is the date they entered and the last column is the date they left. I am trying to create a new table on Power BI that calculates the occupancy for each client per month.

 

I have read a lot of topics and can't find something that works. 

 

I attach pbix and examples.

 

Thank you very much,

 

DM

 

https://www.dropbox.com/s/9gjwxikfwoipjbi/days%20between%202%20dates%20and%20by%20month.pbix?dl=0

https://www.dropbox.com/s/q0qij4lo09oo3bb/Occupancy1.png?dl=0

https://www.dropbox.com/s/p36deh0b894glvs/Occupancy2.png?dl=0

1 ACCEPTED SOLUTION
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @DM_BI 

You may create a measure like below:

Measure = 
CALCULATE (
    COUNTROWS ( DimDate ),
    FILTER (
        GENERATE ( DimDate, Hoja1 ),
        Hoja1[Admit] < DimDate[Date]
            && Hoja1[Departure] >= DimDate[Date]
    )
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @DM_BI 

You may create a measure like below:

Measure = 
CALCULATE (
    COUNTROWS ( DimDate ),
    FILTER (
        GENERATE ( DimDate, Hoja1 ),
        Hoja1[Admit] < DimDate[Date]
            && Hoja1[Departure] >= DimDate[Date]
    )
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi DM

 

Does your calculation require "Time" to be taken into account or just days? If not, you can firstly create a calculated column, then create a measure. 

 

The calculated column, will work out the days between the dates:

OccupancyDays = 
DATEDIFF([entereddate], [leftdate], day)

You can then create a sum measure to calculate the total time spent.

Total Occcupancy = 
CALCULATE
      SUM([OccupancyDays])
)

When you then drag in your person ID and the month into an axis, using your new measure you will see the total time spent.

 

Hope that helps.

 

Thanks

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.

Top Solution Authors
Top Kudoed Authors