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
Anonymous
Not applicable

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 @Anonymous 

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 @Anonymous 

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] )
        )
    )
)
Anonymous
Not applicable

Thank you that's working great!

Whitewater100
Solution Sage
Solution Sage

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? 

Anonymous
Not applicable

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
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.

Top Solution Authors