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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
A_Ch
Regular Visitor

Calculate Days in Role/Project

Hi All,

 

I was in need of some help in calculating the number of days between events. I am trying to calculate how long employees were in certain roles or on certain projects. Below is how my data table is modeled.

 

DateEmployee IDRole/ProjectEventDays Employed
1/1/201801New HireNew Hire1
1/2/201801New Hire 2
1/3/201801New Hire 3
1/4/201801Intern 4
1/5/201801Intern 5
1/6/201801Intern 6
1/7/201801Intern 7
1/8/201801Level 1Role Change8
1/9/201801Level 1 9
1/10/201801Level 1 10
1/11/201801Level 1 11
1/12/201801Level 1 12
1/13/201801Level 1 13
1/14/201801Level 1 14
1/15/201801Level 2Role Change15
1/16/201801Level 2 16
1/17/201801Level 2 17

 

In my model, New Hire and Intern are considered as the same position essentially.

Any help is greatly appreciated.

2 REPLIES 2
v-cherch-msft
Employee
Employee

Hi @A_Ch

 

You may refer to below dax to create calculated columns.

Role/Project 2 =
IF ( Table3[Role/Project] = "Intern", "New Hire", Table3[Role/Project] )

 

Long =
COUNTROWS (
    FILTER ( Table3, Table3[Role/Project 2] = EARLIER ( Table3[Role/Project 2] ) )
)

1.png

 

Regards,

Cherie

 

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.
Greg_Deckler
Super User
Super User

I'm guessing a column and use of EARLIER. See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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