cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
H_M
Helper I
Helper I

Average of Averages

Hi, 

I have created the following expression to calculate the average completed jobs per worker per day.

Avg Completions per worker =
DIVIDE (
    DIVIDE (
        CALCULATE (
            COUNTROWS ( 'jobs' ),
            FILTER ( 'jobs', 'jobs'[Status] = "complete" )
        ),
        DISTINCTCOUNT ( 'jobs'[date] )
    ),
    DISTINCTCOUNT ( 'jobs'[worker] )
) 

 This works well for individual workers / individual days.

I need to wrap the expression in some way to sum the result of the averages per day and divide them by the number of days. To give me an average of the average day when looking at data over a week/month an other time period.

 

example of output, and desired output;

worker

Days

Avg Completions per worker

worker 1

15

1.3

worker 2

15

1.3

worker 3

9

1.6

worker 4

19

2.6

expression result

19

1.3

desired result

 

1.7

 

 

 

It doesn’t work currently because of the mix of workers, i.e., not all will work for the full week or every day.

Can anyone help?

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @H_M 

please use

Avg Completions per worker =
AVERAGEX (
    VALUES ( 'jobs'[worker] ),
    CALCULATE (
        DIVIDE (
            DIVIDE (
                CALCULATE (
                    COUNTROWS ( 'jobs' ),
                    FILTER ( 'jobs', 'jobs'[Status] = "complete" )
                ),
                DISTINCTCOUNT ( 'jobs'[date] )
            ),
            DISTINCTCOUNT ( 'jobs'[worker] )
        )
    )
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @H_M 

please use

Avg Completions per worker =
AVERAGEX (
    VALUES ( 'jobs'[worker] ),
    CALCULATE (
        DIVIDE (
            DIVIDE (
                CALCULATE (
                    COUNTROWS ( 'jobs' ),
                    FILTER ( 'jobs', 'jobs'[Status] = "complete" )
                ),
                DISTINCTCOUNT ( 'jobs'[date] )
            ),
            DISTINCTCOUNT ( 'jobs'[worker] )
        )
    )
)

Thank you that's working great!

Whitewater100
Super User
Super User

Hi:

It would be great if you had dates for the workers (Start Date  End Date) in your fact table. Then you join your fact table to a Date Table. Date Table is marked as Date Table in a one to many relationship with your fact table. You'd also have a dimension table for your workers as well. (Workers table is just the list of unique workers with theri ID with relationship to your fact table.  If you have data like this, I can potentially show a solution. Do you have data on excel or sample pbix to share? 

Hi thanks for your reply. The workers don't have a start and end date as such, they are assined to the jobs, so a pool of 4 workers would have 3 working on day one, 2 on day two, 4 on day three and 1 on day four but the expression I have will total the workers as 4 and divide the total jobs by that and the days, reducing the average too much. I have a closed model so can't make any amendments to the underliing structure. Only Dax calulations.

Helpful resources

Announcements
collabdays lisbon

CollabDays Lisbon - 26 November 2022

Sessions include practical, hands-on experience that will help you take the next step in your career and know-how.

Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.