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
deboec
Helper I
Helper I

Working Days per Employee

Hi,

 

I have a table that shows records for every activity of employees [Activity]:

IDActivity_IDEmployee_IDDateDurationCompleted
11902021/09/0101
21912021/09/0101
31912021/09/0201
42902021/09/0110
53922021/09/0310
61902021/09/0301
71922021/09/0201
81932021/09/0100

 

I need a measure that calculates the days an employee [Employee_ID] worked, meaning if an employee has a record in the [Activity] table on any given date it should count as 1.

Another problem is that an employee can create an activity before the actual day and has to check a box after the activity so it is shown in the table as [Completed] = 1. This on the other hand only occurs if the [Activity_ID] = 1. If [Activity_ID] is 2 or 3 [Completed] will always be 0 but [Duration] will either be 1 or 0.5 (for full day or half day).

 

I created measures for 3 different Activities [Activity_ID], e.g. for [Activity_ID] =1

 

 

Same for [Activity_ID] =2 and [Activity_ID] =3.

For the total days I would then create another measure with an Addition of the 3 different measures.

 

If I display this in a matrix visual however, I get the right Days per Employee but the total is of course also the DISTINCTCOUNT() of the days in the table (matrix for example table above):

Employee_IDDays Activity1
902
912
922
Total 

3 (for the 3 distinct dates in the table with an activity)

 

What I want displayed is the sum as the Total in the matrix.

Thank you for your help

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @deboec,

You can add the 'activity id' field to the table visual and use the below measure formula to calculate workdays of each activity and grouped by employee:

Days Activity =
CALCULATE (
    DISTINCTCOUNT ( Activity[Date] ),
    FILTER ( ALLSELECTED ( Activity ), Activity[Completed] = 1 ),
    VALUES ( Activity[Activity_ID] )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @deboec,

You can add the 'activity id' field to the table visual and use the below measure formula to calculate workdays of each activity and grouped by employee:

Days Activity =
CALCULATE (
    DISTINCTCOUNT ( Activity[Date] ),
    FILTER ( ALLSELECTED ( Activity ), Activity[Completed] = 1 ),
    VALUES ( Activity[Activity_ID] )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
deboec
Helper I
Helper I

Forgot to post the measure für Working Days for Activity1, but here it is:

Days Activity1 =
CALCULATE(
          DISTINCTCOUNT(
                    Activity[Date]
          ),
          Activity[Activity_ID] = 1,
          Activity[Completed] = 1
)

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.