Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Average duration based on a criteria

Hello !
 
I'm trying to calculate the average duration of all my tasks filtred by :
- Column "Nom du compartiment" = "Bench"
- Column "Progression" = "Terminé"
(see picture 1)
 
The duration of each task is in a column called "soustraction" (created with Power Query)  
 It is "Date de fin"-"Date de début"
(see picture 2)
 
I tried a lot of things, and there is a mistake on this part : 
CALCULATE (
SUM ( 'Tâches'[Soustraction] )
But I can't find the solution. Here is my complete formula
 
average =
IF ( COUNTROWS(
FILTER(
ALL('Tâches'),

 

'Tâches'[Nom du Compartiment]="Bench"&&
'Tâches'[Progression]="Terminé"

 

CALCULATE (
SUM ( 'Tâches'[Soustraction] )
)
/ CALCULATE (
COUNT ( 'Tâches'[Nom de tâche] ),
COUNTROWS(
FILTER(
ALL('Tâches'),
'Tâches'[Nom du Compartiment]="Bench"&&
'Tâches'[Progression]="En cours"
)
 
Thanks for advance !
Jdubois_0-1594394539679.pngJdubois_1-1594394573815.png

 

 

 

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

I'm not clear about your formula. Is "average" a entire one? If it is, for the formula [CALCULATE (SUM ( 'Tâches'[Soustraction] )], it will return an aggregation value. You can't add it directly into FILTER function. There should be an Boolean expression like ['Tâches'[Nom du Compartiment]="Bench"&&'Tâches'[Progression]="Terminé"] or [&&CALCULATE (SUM ( 'Tâches'[Soustraction] ) >0].

https://docs.microsoft.com/en-us/dax/filter-function-dax

 

Can you please share the logic of calculation and your expected output? Then we will understand more clearly about your requirement.

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello @v-xuding-msft !

 

I want to calculate the average number on the "soustraction" column for the lines in which : 

- Progression = "Terminées"

- Nom du compartiment = "Bench"

 

With my example, I wanted to get (16 + 9 + 9) /3 = 11.33

 

Thanks for advance !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.