web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Help with DateDiff and...
Power Apps
Unanswered

Help with DateDiff and Average

(0) ShareShare
ReportReport
Posted on by 198

 

I am trying to calculate the average of the differences between two dates within a SharePoint list. Here is my formula, but it is not showing any values even after removing the filters.In some cases, the values of these dates will also be empty in the list.

 

 

If(Dropdown1.SelectedText.Value="Desenvolvimento";Text(Average(
    AddColumns(Filter('Entregas de Desenvolvimento'; 'Work Item'="Requisicao"&& Situação="Fechado" && And(Or(IsBlank(DatePicker_Start.SelectedDate);'Data Criado'>= DatePicker_Start.SelectedDate);
Or(IsBlank(DatePicker_End.SelectedDate); 'Data Criado' <= DatePicker_End.SelectedDate)));
        "_diff"; DateDiff('Data Backlog'; 'Data Closed';TimeUnit.Days)
    );
    _diff
);
"0"
);Text(Average(
    AddColumns(Filter('Entregas de Infra'; 'Work Item'="Requisicao"&& Situação="Fechado" && And(Or(IsBlank(DatePicker_Start.SelectedDate)'Data Criado' >= DatePicker_Start.SelectedDate);
Or(IsBlank(DatePicker_End.SelectedDate); 'Data Criado'<= DatePicker_End.SelectedDate)));
        "_diff"; DateDiff('Data Backlog'; 'Data Closed';TimeUnit.Days)
    );
    _diff
);
"0"
))
 
Pizzolati_0-1707400971991.png

 

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    on at

    Hi @Pizzolati ,

     

    I cannot see the Data Backlog column from in your screenshot. In DateDiff function, it requires the two dates are neither blank, otherwise it returns blank as result. 

     

    Please try and add another criteria in your formula?

    If(
     Dropdown1.SelectedText.Value="Desenvolvimento";
     Text(
     Average(
     AddColumns(
     Filter(
     'Entregas de Desenvolvimento'; 
     'Work Item'="Requisicao"&& Situação="Fechado" 
     &&
     !(IsBlank('Data Criado'))
     && 
     And(
     Or(IsBlank(DatePicker_Start.SelectedDate);'Data Criado'>= DatePicker_Start.SelectedDate);
     Or(IsBlank(DatePicker_End.SelectedDate); 'Data Criado' <= DatePicker_End.SelectedDate)
     )
     );
     "_diff"; 
     DateDiff('Data Backlog'; 'Data Closed';TimeUnit.Days)
     );
     _diff
     );
     "0"
     );
     Text(
     Average(
     AddColumns(
     Filter(
     'Entregas de Infra'; 
     'Work Item'="Requisicao"&& Situação="Fechado"
     &&
     !(IsBlank('Data Criado')) 
     && 
     And(
     Or(IsBlank(DatePicker_Start.SelectedDate);'Data Criado' >= DatePicker_Start.SelectedDate);
     Or(IsBlank(DatePicker_End.SelectedDate); 'Data Criado'<= DatePicker_End.SelectedDate))
     );
     "_diff"; 
     DateDiff('Data Backlog'; 'Data Closed';TimeUnit.Days)
     );
     _diff
     );
     "0"
     )
    )

     

    Best regards,

  • Pizzolati Profile Picture
    198 on at

    Pizzolati_0-1707483484699.png

    So in some cases I'll have value and in others I won't (as in the new image I sent). So even with the change in the formula you sent, no value is sent.

  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @Pizzolati ,

     

    If it's ok to handle the average of blank dates to be 0, then the formula would be the follows:

    If(
     Dropdown1.SelectedText.Value="Desenvolvimento";
     Text(
     Average(
     AddColumns(
     Filter(
     'Entregas de Desenvolvimento'; 
     'Work Item'="Requisicao"&& Situação="Fechado" 
     && 
     And(
     Or(IsBlank(DatePicker_Start.SelectedDate);'Data Criado'>= DatePicker_Start.SelectedDate);
     Or(IsBlank(DatePicker_End.SelectedDate); 'Data Criado' <= DatePicker_End.SelectedDate)
     )
     );
     "_diff"; 
     If(IsBlank('Data Backlog'); 0; DateDiff('Data Backlog'; 'Data Closed';TimeUnit.Days))
     );
     _diff
     );
     "0"
     );
     Text(
     Average(
     AddColumns(
     Filter(
     'Entregas de Infra'; 
     'Work Item'="Requisicao"&& Situação="Fechado"
     &&
     And(
     Or(IsBlank(DatePicker_Start.SelectedDate);'Data Criado' >= DatePicker_Start.SelectedDate);
     Or(IsBlank(DatePicker_End.SelectedDate); 'Data Criado'<= DatePicker_End.SelectedDate))
     );
     "_diff"; 
     If(IsBlank('Data Backlog'); 0; DateDiff('Data Backlog'; 'Data Closed';TimeUnit.Days))
     );
     _diff
     );
     "0"
     )
    )

     

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard