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
jernau
Frequent Visitor

Measure to average duration in related rows

Hello,

 

I want to create a measure which will calculate the average duration of task(s) completed by a machine.

 

There are two task types: 'Task', and 'Parent Task'.  Every 'Parent Task' has one 'Task'.

 

All of the data I require is held against the 'Task', except for one column which is recorded against the 'Parent Task'.

 

What I want to achieve, looks like this (the right-most column); can anyone suggest how to do this?

  

Machine NumberTaskDurationParentTaskDesired Duration Measure Output (average duration)
MCN51T10P11
MCN51T20P23
MCN51P11<blank><blank> or 0
MCN51P23<blank><blank> or 0
Total  4 2

 

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @jernau,

 

Please try the formula below.

Measure 2 =
AVERAGEX (
    'Table1',
    CALCULATE (
        AVERAGE ( Table1[Duration] ),
        FILTER ( ALL ( Table1 ), Table1[Task] = EARLIER ( Table1[ParentTask] ) )
    )
)

Measure_to_average_duration_in_related_rows

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-jiascu-msft
Employee
Employee

Hi @jernau,

 

Please try the formula below.

Measure 2 =
AVERAGEX (
    'Table1',
    CALCULATE (
        AVERAGE ( Table1[Duration] ),
        FILTER ( ALL ( Table1 ), Table1[Task] = EARLIER ( Table1[ParentTask] ) )
    )
)

Measure_to_average_duration_in_related_rows

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

That worked really well, thank you Dale!

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.