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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dfeuer
New Member

Calculate number of teams on hire based off of start and end date

I am trying to calculate the number of "team days" per day based off of a start and end date for each team. 

 

Team        Start Date      End Date

Team 1      1/1/2016        12/31/2016
Team 2      4/13/2016      11/19/2016
Team 3      5/8/2016        11/29/2016
Team 4      4/22/2016      11/19/2016

 

in this case, for example, Jan 1 would have 1 day, since only 1team is working then, but June 12 would have 4 since all 4 teams are working. I am trying to get these values for each day of the year.

 

Thank you!

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @dfeuer,

 

Create a Dates table (without relationship) put the date of this table in youe axis/table/... and then add this measure

 

Teams =
VAR dates_slicer =
    MIN ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        COUNTA ( Teams[Team] );
        Teams[Start Date] <= dates_slicer;
        Teams[End Date] >= dates_slicer
    )

Should give you what you need.

 

 

Regards

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2

MFelix answer is right, if you are interested in performance because you are working on a large dataset, you might also take a look at this article I wrote some time ago: https://www.sqlbi.com/articles/analyzing-events-with-a-duration-in-dax/, But, if yours is a small dataset, there's no need to superoptimize it and you can safely go with the simpler formula.

 

Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI
MFelix
Super User
Super User

Hi @dfeuer,

 

Create a Dates table (without relationship) put the date of this table in youe axis/table/... and then add this measure

 

Teams =
VAR dates_slicer =
    MIN ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        COUNTA ( Teams[Team] );
        Teams[Start Date] <= dates_slicer;
        Teams[End Date] >= dates_slicer
    )

Should give you what you need.

 

 

Regards

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.