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
jl20
Helper IV
Helper IV

Average of a Distinct Count - DAX needed

Hi all,

 

I'm looking to write a measure that calculates the average number of jobs an employee works per day (they may work one or more than one job per day). I'm not interested in days where they don't work (i.e., the average should only include dates in which they work). It will be easiest to just show you what I'm trying to achieve with some sample data. Looking for the code that will get me the bolded results below.

 

Dataset:  
Job NumberDate WorkedEmployee #
2652710/1/2015Employee 1
2652710/2/2015Employee 1
2826610/1/2015Employee 2
2929610/1/2015Employee 2
2801210/2/2015Employee 2
2770810/5/2015Employee 2
2826610/5/2015Employee 2
2635310/1/2015Employee 3
2680310/1/2015Employee 3
2680310/2/2015Employee 3
2680310/3/2015Employee 3
   
Desired Results: 
EmployeeAverage # of Distinct Jobs per DayDays Worked
Employee 11.02
Employee 21.73
Employee 31.33

 

Thanks in advance for your help!

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

This should give you the desired output Smiley Happy

Average # of Distinct Jobs per Day =
DIVIDE (
    CALCULATE (
        COUNTA ( 'Table'[Job Number] ),
        ALLEXCEPT ( 'Table', 'Table'[Employee #] )
    ),
    DISTINCTCOUNT ( 'Table'[Date Worked] ),
    0
)

Average # of Distinct Jobs per Day.png 

View solution in original post

1 REPLY 1
Sean
Community Champion
Community Champion

This should give you the desired output Smiley Happy

Average # of Distinct Jobs per Day =
DIVIDE (
    CALCULATE (
        COUNTA ( 'Table'[Job Number] ),
        ALLEXCEPT ( 'Table', 'Table'[Employee #] )
    ),
    DISTINCTCOUNT ( 'Table'[Date Worked] ),
    0
)

Average # of Distinct Jobs per Day.png 

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.